Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WaitForMultipleObjects not waiting Pin
wjeanveau9-Jun-08 13:10
wjeanveau9-Jun-08 13:10 
GeneralRe: WaitForMultipleObjects not waiting Pin
Joe Woodbury9-Jun-08 13:17
professionalJoe Woodbury9-Jun-08 13:17 
GeneralRe: WaitForMultipleObjects not waiting Pin
wjeanveau9-Jun-08 13:23
wjeanveau9-Jun-08 13:23 
GeneralRe: WaitForMultipleObjects not waiting Pin
Joe Woodbury9-Jun-08 13:42
professionalJoe Woodbury9-Jun-08 13:42 
GeneralRe: WaitForMultipleObjects not waiting Pin
wjeanveau9-Jun-08 14:36
wjeanveau9-Jun-08 14:36 
GeneralRe: WaitForMultipleObjects not waiting Pin
Joe Woodbury9-Jun-08 15:31
professionalJoe Woodbury9-Jun-08 15:31 
GeneralRe: WaitForMultipleObjects not waiting Pin
wjeanveau9-Jun-08 17:10
wjeanveau9-Jun-08 17:10 
Questionreading bits from file Pin
botnet9-Jun-08 11:06
botnet9-Jun-08 11:06 
Hi Guys,

I've been searching extensively over the past couple of days but still have trouble reading bits from a file. I'm trying to read the header of an MPEG ts file.

Here is what I have:
<br />
<br />
// header structure<br />
struct TS_PACKET_HEADER  {<br />
     unsigned int sync_byte:8; <br />
     unsigned int payload_unit_start_indicator:1;<br />
     unsigned int transport_error_indicator:1;<br />
     unsigned int transport_priority:1;<br />
     unsigned int PID:13;<br />
     unsigned int scrambling_control:2;<br />
     unsigned int adaptive_field_exists:2;<br />
     unsigned int payload_data_exists:1;<br />
     unsigned int continuity_counter:4;<br />
};<br />
<br />
...<br />
<br />
<br />
// the code to read from file into structure<br />
<br />
    int size;<br />
    unsigned char* buffer;<br />
<br />
    std::ifstream inputFile("mpeg.ts", std::ios::in | std::ios::binary);<br />
    if (inputFile.is_open())    <br />
    {<br />
        size = 4;<br />
        buffer = new unsigned char[size];<br />
        inputFile.seekg(0);<br />
        inputFile.read( reinterpret_cast<char*>(buffer), size);<br />
<br />
        TS_PACKET_HEADER header = * (TS_PACKET_HEADER*) buffer;<br />
    }<br />
</char*>


The first byte reads fine but the next two bytes (payload_unit_start_indicator, transport_error_indicator, transport_priority and PID) read incorrectly.

Where am i going wrong and is there a better way to do this?

Packet header information:
http://en.wikipedia.org/wiki/Transport_stream#Important_elements_of_a_transport_stream[^]
AnswerRe: reading bits from file Pin
Jijo.Raj9-Jun-08 18:38
Jijo.Raj9-Jun-08 18:38 
GeneralRe: reading bits from file Pin
achainard10-Jun-08 2:45
achainard10-Jun-08 2:45 
GeneralRe: reading bits from file Pin
botnet10-Jun-08 13:09
botnet10-Jun-08 13:09 
AnswerRe: reading bits from file Pin
krmed10-Jun-08 6:08
krmed10-Jun-08 6:08 
QuestionBlank printout to printer Pin
Joe Smith IX9-Jun-08 7:04
Joe Smith IX9-Jun-08 7:04 
AnswerRe: Blank printout to printer [modified] Pin
Nelek9-Jun-08 8:12
protectorNelek9-Jun-08 8:12 
GeneralRe: Blank printout to printer Pin
Joe Smith IX9-Jun-08 8:33
Joe Smith IX9-Jun-08 8:33 
GeneralRe: Blank printout to printer Pin
Nelek9-Jun-08 8:59
protectorNelek9-Jun-08 8:59 
GeneralRe: Blank printout to printer Pin
Joe Smith IX9-Jun-08 9:22
Joe Smith IX9-Jun-08 9:22 
GeneralRe: Blank printout to printer Pin
Nelek9-Jun-08 9:34
protectorNelek9-Jun-08 9:34 
GeneralRe: Blank printout to printer Pin
Joe Smith IX9-Jun-08 9:53
Joe Smith IX9-Jun-08 9:53 
GeneralRe: Blank printout to printer Pin
Nelek9-Jun-08 10:02
protectorNelek9-Jun-08 10:02 
GeneralRe: Blank printout to printer Pin
Joe Smith IX9-Jun-08 10:18
Joe Smith IX9-Jun-08 10:18 
GeneralRe: Blank printout to printer Pin
Nelek9-Jun-08 10:32
protectorNelek9-Jun-08 10:32 
GeneralRe: Blank printout to printer Pin
Joe Smith IX9-Jun-08 16:44
Joe Smith IX9-Jun-08 16:44 
GeneralRe: Blank printout to printer Pin
Nelek11-Jun-08 8:16
protectorNelek11-Jun-08 8:16 
NewsRe: Blank printout to printer Pin
bulg9-Jun-08 11:13
bulg9-Jun-08 11:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.