diff --git a/src/lib_ccx/asf_functions.c b/src/lib_ccx/asf_functions.c index 13449485a..d4f43b80b 100644 --- a/src/lib_ccx/asf_functions.c +++ b/src/lib_ccx/asf_functions.c @@ -39,7 +39,7 @@ uint32_t asf_readval(void *val, int ltype) return rval; } -char *guidstr(void *val) +char *gui_data_string(void *val) { static char sbuf[40]; @@ -75,31 +75,31 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) int reentry = 1; // Variables for Header Object - int64_t DataPacketsCount = 0; - int BroadcastFlag = 0; - int SeekableFlag = 0; - uint32_t MinPacketSize = 0; - uint32_t MaxPacketSize = 0; + int64_t data_packets_count = 0; + int broadcast_flag = 0; + int seekable_flag = 0; + uint32_t min_packet_size = 0; + uint32_t max_packet_size = 0; // Data Object Loop - int datapacketlength = 0; // Collect the read header bytes + int data_packet_length = 0; // Collect the read header bytes // Payload parsing information - int SequenceType = 0; // ASF - int PaddingLType = 0; // ASF - uint32_t Sequence = 0; - uint32_t SendTime = 0; + int sequence_type = 0; // ASF + int padding_l_type = 0; // ASF + uint32_t sequence = 0; + uint32_t send_time = 0; - int payloadparsersize = 0; // Infered (PacketLType + SequenceType + PaddingLType + 6); + int payload_parser_size = 0; // Infered (PacketLType + sequence_type + padding_l_type + 6); - uint32_t OffsetMediaLength = 0; // ASF - uint32_t ReplicatedLength = 0; // ASF + uint32_t offset_media_length = 0; // ASF + uint32_t replicated_length = 0; // ASF // Last media number. Used to determine a new PES, mark uninitialized. - uint32_t curmedianumber = 0xFFFFFFFF; + uint32_t current_media_number = 0xFFFFFFFF; - unsigned char *curpos; - int64_t getbytes; + unsigned char *current_position; + int64_t get_bytes; size_t result = 0; struct demuxer_data *data; @@ -194,12 +194,12 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) asf_data_container.parsebufsize = (long)asf_data_container.HeaderObjectSize; } - curpos = asf_data_container.parsebuf + 30; - getbytes = asf_data_container.HeaderObjectSize - 30; + current_position = asf_data_container.parsebuf + 30; + get_bytes = asf_data_container.HeaderObjectSize - 30; - result = buffered_read(ctx->demux_ctx, curpos, (int) getbytes); + result = buffered_read(ctx->demux_ctx, current_position, (int) get_bytes); ctx->demux_ctx->past += result; - if (result!=getbytes) + if (result!=get_bytes) { mprint("Premature end of file!\n"); end_of_file=1; @@ -208,174 +208,174 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) dbg_print(CCX_DMT_PARSE, "Reading header objects\n"); - while (curpos < asf_data_container.parsebuf + asf_data_container.HeaderObjectSize) + while (current_position < asf_data_container.parsebuf + asf_data_container.HeaderObjectSize) { - int64_t hpobjectsize = *((int64_t*)(curpos+16)); // Local + int64_t hpobjectsize = *((int64_t*)(current_position+16)); // Local - if( !memcmp(curpos, ASF_FILE_PROPERTIES, 16 ) ) + if( !memcmp(current_position, ASF_FILE_PROPERTIES, 16 ) ) { // Mandatory Object, only one. dbg_print(CCX_DMT_PARSE, "\nFile Properties Object (size: %lld)\n", hpobjectsize); - asf_data_container.FileSize = *((int64_t*)(curpos + 40)); - DataPacketsCount = *((int64_t*)(curpos+56)); - BroadcastFlag = 0x1 & curpos[88]; - SeekableFlag = 0x2 & curpos[88]; - MinPacketSize = *((uint32_t*)(curpos+92)); - MaxPacketSize = *((uint32_t*)(curpos+96)); + asf_data_container.FileSize = *((int64_t*)(current_position + 40)); + data_packets_count = *((int64_t*)(current_position+56)); + broadcast_flag = 0x1 & current_position[88]; + seekable_flag = 0x2 & current_position[88]; + min_packet_size = *((uint32_t*)(current_position+92)); + max_packet_size = *((uint32_t*)(current_position+96)); - dbg_print(CCX_DMT_PARSE, "FileSize: %lld Packet count: %lld\n", asf_data_container.FileSize, DataPacketsCount); - dbg_print(CCX_DMT_PARSE, "Broadcast: %d - Seekable: %d\n", BroadcastFlag, SeekableFlag); - dbg_print(CCX_DMT_PARSE, "MiDPS: %d MaDPS: %d\n", MinPacketSize, MaxPacketSize); + dbg_print(CCX_DMT_PARSE, "FileSize: %lld Packet count: %lld\n", asf_data_container.FileSize, data_packets_count); + dbg_print(CCX_DMT_PARSE, "Broadcast: %d - Seekable: %d\n", broadcast_flag, seekable_flag); + dbg_print(CCX_DMT_PARSE, "MiDPS: %d MaDPS: %d\n", min_packet_size, max_packet_size); } - else if( !memcmp(curpos,ASF_STREAM_PROPERTIES, 16 ) ) + else if( !memcmp(current_position,ASF_STREAM_PROPERTIES, 16 ) ) { dbg_print(CCX_DMT_PARSE, "\nStream Properties Object (size: %lld)\n", hpobjectsize); - if( !memcmp(curpos+24, ASF_VIDEO_MEDIA, 16 ) ) + if( !memcmp(current_position+24, ASF_VIDEO_MEDIA, 16 ) ) { - asf_data_container.StreamProperties.VideoStreamNumber = *(curpos + 72) & 0x7F; + asf_data_container.StreamProperties.VideoStreamNumber = *(current_position + 72) & 0x7F; dbg_print(CCX_DMT_PARSE, "Stream Type: ASF_Video_Media\n"); dbg_print(CCX_DMT_PARSE, "Video Stream Number: %d\n", asf_data_container.StreamProperties.VideoStreamNumber); } - else if( !memcmp(curpos+24, ASF_AUDIO_MEDIA, 16 ) ) + else if( !memcmp(current_position+24, ASF_AUDIO_MEDIA, 16 ) ) { - asf_data_container.StreamProperties.AudioStreamNumber = *(curpos + 72) & 0x7F; + asf_data_container.StreamProperties.AudioStreamNumber = *(current_position + 72) & 0x7F; dbg_print(CCX_DMT_PARSE, "Stream Type: ASF_Audio_Media\n"); dbg_print(CCX_DMT_PARSE, "Audio Stream Number: %d\n", asf_data_container.StreamProperties.AudioStreamNumber); } else { dbg_print(CCX_DMT_PARSE, "Stream Type: %s\n", - guidstr(curpos+24)); - dbg_print(CCX_DMT_PARSE, "Stream Number: %d\n", *(curpos+72) & 0x7F ); + gui_data_string(current_position+24)); + dbg_print(CCX_DMT_PARSE, "Stream Number: %d\n", *(current_position+72) & 0x7F ); } } - else if( !memcmp(curpos,ASF_HEADER_EXTENSION, 16 ) ) + else if( !memcmp(current_position,ASF_HEADER_EXTENSION, 16 ) ) { dbg_print(CCX_DMT_PARSE, "\nHeader Extension Object (size: %lld)\n", hpobjectsize); - int32_t HeaderExtensionDataSize = *((uint32_t*)(curpos+42)); + int32_t header_extension_data_size = *((uint32_t*)(current_position+42)); // Process Header Extension Data - if ( HeaderExtensionDataSize ) + if ( header_extension_data_size ) { - unsigned char *hecurpos=curpos+46; + unsigned char *header_current_position=current_position+46; - if ( HeaderExtensionDataSize != hpobjectsize - 46 ) + if ( header_extension_data_size != hpobjectsize - 46 ) fatal(EXIT_NOT_CLASSIFIED, "In asf_getmoredata: Incorrect HeaderExtensionDataSize value, cannot continue."); dbg_print(CCX_DMT_PARSE, "\nReading Header Extension Sub-Objects\n"); - while( hecurpos < curpos+46 + HeaderExtensionDataSize ) + while( header_current_position < current_position+46 + header_extension_data_size ) { - int64_t heobjectsize = *((int64_t*)(hecurpos+16)); // Local + int64_t header_object_size = *((int64_t*)(header_current_position+16)); // Local - if( !memcmp(hecurpos,ASF_EXTENDED_STREAM_PROPERTIES, 16 ) ) + if( !memcmp(header_current_position,ASF_EXTENDED_STREAM_PROPERTIES, 16 ) ) { - dbg_print(CCX_DMT_PARSE, "\nExtended Stream Properties Object (size: %lld)\n", heobjectsize); - int StreamNumber = *((uint16_t*)(hecurpos+72)); - int StreamNameCount = *((uint16_t*)(hecurpos+84)); - int PayloadExtensionSystemCount = *((uint16_t*)(hecurpos+86)); + dbg_print(CCX_DMT_PARSE, "\nExtended Stream Properties Object (size: %lld)\n", header_object_size); + int stream_number = *((uint16_t*)(header_current_position+72)); + int stream_name_count = *((uint16_t*)(header_current_position+84)); + int payload_ext_system_count = *((uint16_t*)(header_current_position+86)); - unsigned char *estreamproppos=hecurpos+88; + unsigned char *stream_prop_position=header_current_position+88; - int streamnamelength; + int stream_name_length; dbg_print(CCX_DMT_PARSE, "Stream Number: %d NameCount: %d ESCount: %d\n", - StreamNumber, StreamNameCount, PayloadExtensionSystemCount); + stream_number, stream_name_count, payload_ext_system_count); - if ( StreamNumber >= STREAMNUM ) + if ( stream_number >= STREAMNUM ) fatal(CCX_COMMON_EXIT_BUG_BUG, "In asf_getmoredata: STREAMNUM too small. Please file a bug report in GitHub.\n"); - for(int i=0; i PAYEXTNUM ) + if ( payload_ext_system_count > PAYEXTNUM ) fatal(CCX_COMMON_EXIT_BUG_BUG, "In asf_getmoredata: PAYEXTNUM too small. Please file a bug report in GitHub.\n"); - for(int i=0; i8) - dbg_print(CCX_DMT_PARSE, "skipped %d more",DescriptorValueLength-8); + if (descriptor_value_length>8) + dbg_print(CCX_DMT_PARSE, "skipped %d more",descriptor_value_length-8); dbg_print(CCX_DMT_PARSE, " (BYTES)\n"); break; case 2: // BOOL - dbg_print(CCX_DMT_PARSE, "%d (BOOL)\n",*((int32_t*)edescval)); + dbg_print(CCX_DMT_PARSE, "%d (BOOL)\n",*((int32_t*)extended_description_value)); break; case 3: // DWORD - dbg_print(CCX_DMT_PARSE, "%u (DWORD)\n",*((uint32_t*)edescval)); + dbg_print(CCX_DMT_PARSE, "%u (DWORD)\n",*((uint32_t*)extended_description_value)); break; case 4: // QWORD - dbg_print(CCX_DMT_PARSE, "%llu (QWORD)\n",*((uint64_t*)edescval)); + dbg_print(CCX_DMT_PARSE, "%llu (QWORD)\n",*((uint64_t*)extended_description_value)); break; case 5: // WORD - dbg_print(CCX_DMT_PARSE, "%u (WORD)\n",(int)*((uint16_t*)edescval)); + dbg_print(CCX_DMT_PARSE, "%u (WORD)\n",(int)*((uint16_t*)extended_description_value)); break; default: fatal(CCX_COMMON_EXIT_BUG_BUG, "In asf_getmoredata: Impossible value for DescriptorValueDataType. Please file a bug report in GitHub.\n"); break; } - if(!memcmp(econtentpos+2, L"WM/VideoClosedCaptioning" - ,DescriptorNameLength)) + if(!memcmp(ext_content_position+2, L"WM/VideoClosedCaptioning" + ,descriptor_name_length)) { // This flag would be really usefull if it would be // reliable - it isn't. - asf_data_container.VideoClosedCaptioningFlag = *((int32_t*)edescval); + asf_data_container.VideoClosedCaptioningFlag = *((int32_t*)extended_description_value); dbg_print(CCX_DMT_PARSE, "Found WM/VideoClosedCaptioning flag: %d\n", asf_data_container.VideoClosedCaptioningFlag); } - econtentpos+=6+DescriptorNameLength+DescriptorValueLength; + ext_content_position+=6+descriptor_name_length+descriptor_value_length; } } - else if( !memcmp(curpos,ASF_STREAM_BITRATE_PROPERTIES, 16 ) ) + else if( !memcmp(current_position,ASF_STREAM_BITRATE_PROPERTIES, 16 ) ) { dbg_print(CCX_DMT_PARSE, "\nStream Bitrate Properties Object (size: %lld)\n", hpobjectsize); } else { dbg_print(CCX_DMT_PARSE, "\nGUID: %s size: %lld\n", - guidstr(curpos), hpobjectsize); - dump(CCX_DMT_PARSE, curpos, 16, 0, 0); + gui_data_string(current_position), hpobjectsize); + dump(CCX_DMT_PARSE, current_position, 16, 0, 0); } - curpos += hpobjectsize; + current_position += hpobjectsize; } - if (curpos - asf_data_container.parsebuf != asf_data_container.HeaderObjectSize) + if (current_position - asf_data_container.parsebuf != asf_data_container.HeaderObjectSize) fatal(EXIT_NOT_CLASSIFIED, "Parsing problem: read bytes %ld != header length %lld\nAbort!\n", - (long)(curpos - asf_data_container.parsebuf), asf_data_container.HeaderObjectSize); + (long)(current_position - asf_data_container.parsebuf), asf_data_container.HeaderObjectSize); if (asf_data_container.StreamProperties.VideoStreamNumber == 0) fatal(EXIT_NOT_CLASSIFIED, "No Video Stream Properties Object found. Unable to continue ...\n"); @@ -541,9 +541,9 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) // When reading "Payload parsing information" it occured that "Packet Lenght" // was not set (Packet Length Type 00) and for "Single Payloads" this means - // the Payload Data Length cannot be infered. Use MinPacketSize, MaxPacketSize instead. - if ((MinPacketSize > 0) && (MinPacketSize == MaxPacketSize)) - asf_data_container.PacketSize = MinPacketSize; + // the Payload Data Length cannot be infered. Use min_packet_size, max_packet_size instead. + if ((min_packet_size > 0) && (min_packet_size == max_packet_size)) + asf_data_container.PacketSize = min_packet_size; // Now the Data Object, except for the packages result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf, 50); // No realloc needed. @@ -583,7 +583,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) { int ecinfo = 0; - datapacketlength = 0; + data_packet_length = 0; dbg_print(CCX_DMT_PARSE, "\nReading packet %d/%d\n", asf_data_container.datapacketcur + 1, asf_data_container.TotalDataPackets); @@ -597,7 +597,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) end_of_file=1; return payload_read; } - datapacketlength+=1; + data_packet_length+=1; if (*asf_data_container.parsebuf & 0x80) { int ecdatalength = *asf_data_container.parsebuf & 0x0F; // Small, no realloc needed @@ -614,7 +614,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) end_of_file=1; return payload_read; } - datapacketlength+=ecdatalength; + data_packet_length+=ecdatalength; if (asf_data_container.parsebuf[1] & 0x0F) fatal(EXIT_NOT_CLASSIFIED, "Error correction present. Unable to continue ...\n"); } @@ -635,15 +635,15 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) end_of_file=1; return payload_read; } - datapacketlength+=2; + data_packet_length+=2; asf_data_container.MultiplePayloads = *asf_data_container.parsebuf & 0x01; - SequenceType = (*asf_data_container.parsebuf >> 1) & 0x03; - SequenceType = ASF_TypeLength(SequenceType); + sequence_type = (*asf_data_container.parsebuf >> 1) & 0x03; + sequence_type = ASF_TypeLength(sequence_type); - PaddingLType = (*asf_data_container.parsebuf >> 3) & 0x03; - PaddingLType = ASF_TypeLength(PaddingLType); + padding_l_type = (*asf_data_container.parsebuf >> 3) & 0x03; + padding_l_type = ASF_TypeLength(padding_l_type); asf_data_container.PacketLType = (*asf_data_container.parsebuf >> 5) & 0x03; asf_data_container.PacketLType = ASF_TypeLength(asf_data_container.PacketLType); @@ -660,24 +660,24 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) asf_data_container.StreamNumberLType = (asf_data_container.parsebuf[1] >> 6) & 0x03; asf_data_container.StreamNumberLType = ASF_TypeLength(asf_data_container.StreamNumberLType); - payloadparsersize = asf_data_container.PacketLType + SequenceType + PaddingLType + 6; + payload_parser_size = asf_data_container.PacketLType + sequence_type + padding_l_type + 6; - result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf + 2, payloadparsersize); // No realloc needed + result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf + 2, payload_parser_size); // No realloc needed ctx->demux_ctx->past += result; asf_data_container.dobjectread += result; - if (result!=payloadparsersize) + if (result!=payload_parser_size) { mprint("Premature end of file!\n"); end_of_file=1; return payload_read; } - datapacketlength+=payloadparsersize; + data_packet_length+=payload_parser_size; asf_data_container.PacketLength = asf_readval(asf_data_container.parsebuf + 2, asf_data_container.PacketLType); - Sequence = asf_readval(asf_data_container.parsebuf + 2 + asf_data_container.PacketLType, SequenceType); - asf_data_container.PaddingLength = asf_readval(asf_data_container.parsebuf + 2 + asf_data_container.PacketLType + SequenceType, PaddingLType); + sequence = asf_readval(asf_data_container.parsebuf + 2 + asf_data_container.PacketLType, sequence_type); + asf_data_container.PaddingLength = asf_readval(asf_data_container.parsebuf + 2 + asf_data_container.PacketLType + sequence_type, padding_l_type); // Data Packet ms time stamp - SendTime = *((uint32_t*)(asf_data_container.parsebuf + 2 + asf_data_container.PacketLType + SequenceType + PaddingLType)); + send_time = *((uint32_t*)(asf_data_container.parsebuf + 2 + asf_data_container.PacketLType + sequence_type + padding_l_type)); // If Packet Length is not set use global setting if possible if (asf_data_container.PacketLength == 0) @@ -689,8 +689,8 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) fatal(EXIT_NOT_CLASSIFIED, "In asf_getmoredata: Cannot determine packet length. Unable to continue processing this file.\n"); } - dbg_print(CCX_DMT_PARSE, "Lengths - Packet: %d / Sequence %d / Padding %d\n", - asf_data_container.PacketLength, Sequence, asf_data_container.PaddingLength); + dbg_print(CCX_DMT_PARSE, "Lengths - Packet: %d / sequence %d / Padding %d\n", + asf_data_container.PacketLength, sequence, asf_data_container.PaddingLength); asf_data_container.PayloadLType = 0; // Payload Length Type. <>0 for multiple payloads asf_data_container.PayloadLength = 0; // Payload Length (for multiple payloads) @@ -709,7 +709,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) end_of_file=1; return payload_read; } - datapacketlength+=1; + data_packet_length+=1; asf_data_container.PayloadLType = (*plheader >> 6) & 0x03; asf_data_container.PayloadLType = ASF_TypeLength(asf_data_container.PayloadLType); @@ -737,49 +737,49 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) else dbg_print(CCX_DMT_PARSE, "\nMultiple payloads %d/%d\n", asf_data_container.payloadcur + 1, asf_data_container.NumberOfPayloads); - int payloadheadersize = 1 + asf_data_container.MediaNumberLType + asf_data_container.OffsetMediaLType + asf_data_container.ReplicatedLType; + int payload_header_size = 1 + asf_data_container.MediaNumberLType + asf_data_container.OffsetMediaLType + asf_data_container.ReplicatedLType; - result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf, payloadheadersize); // No realloc needed + result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf, payload_header_size); // No realloc needed ctx->demux_ctx->past += result; asf_data_container.dobjectread += result; - if (result!=payloadheadersize) + if (result!=payload_header_size) { mprint("Premature end of file!\n"); end_of_file=1; return payload_read; } - datapacketlength+=payloadheadersize; + data_packet_length+=payload_header_size; asf_data_container.PayloadStreamNumber = *asf_data_container.parsebuf & 0x7F; asf_data_container.KeyFrame = (*asf_data_container.parsebuf & 0x80) && 1; asf_data_container.PayloadMediaNumber = asf_readval(asf_data_container.parsebuf + 1, asf_data_container.MediaNumberLType); - OffsetMediaLength = asf_readval(asf_data_container.parsebuf + 1 + asf_data_container.MediaNumberLType, asf_data_container.OffsetMediaLType); - ReplicatedLength = asf_readval(asf_data_container.parsebuf + 1 + asf_data_container.MediaNumberLType + asf_data_container.OffsetMediaLType, asf_data_container.ReplicatedLType); + offset_media_length = asf_readval(asf_data_container.parsebuf + 1 + asf_data_container.MediaNumberLType, asf_data_container.OffsetMediaLType); + replicated_length = asf_readval(asf_data_container.parsebuf + 1 + asf_data_container.MediaNumberLType + asf_data_container.OffsetMediaLType, asf_data_container.ReplicatedLType); - if (ReplicatedLength == 1) + if (replicated_length == 1) fatal(EXIT_NOT_CLASSIFIED, "Cannot handle compressed data...\n"); - if ((long)ReplicatedLength > asf_data_container.parsebufsize) + if ((long)replicated_length > asf_data_container.parsebufsize) { - asf_data_container.parsebuf = (unsigned char*)realloc(asf_data_container.parsebuf, ReplicatedLength); + asf_data_container.parsebuf = (unsigned char*)realloc(asf_data_container.parsebuf, replicated_length); if (!asf_data_container.parsebuf) fatal(EXIT_NOT_ENOUGH_MEMORY, "In asf_getmoredata: Not enough memory for buffer, unable to continue.\n"); - asf_data_container.parsebufsize = ReplicatedLength; + asf_data_container.parsebufsize = replicated_length; } - result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf, (long)ReplicatedLength); + result = buffered_read(ctx->demux_ctx, asf_data_container.parsebuf, (long)replicated_length); ctx->demux_ctx->past += result; asf_data_container.dobjectread += result; - if (result!=ReplicatedLength) + if (result!=replicated_length) { mprint("Premature end of file!\n"); end_of_file=1; return payload_read; } // Parse Replicated data - unsigned char *reppos = asf_data_container.parsebuf; - int MediaObjectSize = 0; - int PresentationTimems = 0; //Payload ms time stamp + unsigned char *replicate_position = asf_data_container.parsebuf; + int media_object_size = 0; + int presentation_time_millis = 0; //Payload ms time stamp int extsize = 0; // int32_t dwVersion = 0; // int32_t unknown = 0; @@ -787,35 +787,35 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) int64_t rtEnd = 0; // dvr-ms 100ns time stamp end // Always at least 8 bytes long, see 7.3.1 - MediaObjectSize = *((uint16_t*)(asf_data_container.parsebuf)); - PresentationTimems = *((uint16_t*)(asf_data_container.parsebuf + 4)); - reppos += 8; + media_object_size = *((uint16_t*)(asf_data_container.parsebuf)); + presentation_time_millis = *((uint16_t*)(asf_data_container.parsebuf + 4)); + replicate_position += 8; dbg_print(CCX_DMT_PARSE, "Stream# %d[%d] Media# %d Offset/Size: %d/%d\n", asf_data_container.PayloadStreamNumber, asf_data_container.KeyFrame, asf_data_container.PayloadMediaNumber, - OffsetMediaLength, MediaObjectSize); + offset_media_length, media_object_size); // Loop over Payload Extension Systems for (int i = 0; i 0) { - // dwVersion = *((uint32_t*)(reppos+0)); - // unknown = *((uint32_t*)(reppos+4)); - rtStart = *((int64_t*)(reppos+8)); - rtEnd = *((int64_t*)(reppos+16)); + // dwVersion = *((uint32_t*)(replicate_position+0)); + // unknown = *((uint32_t*)(replicate_position+4)); + rtStart = *((int64_t*)(replicate_position+8)); + rtEnd = *((int64_t*)(replicate_position+16)); //printf("dwVersion: %d unknown: 0x%04X\n", dwVersion, unknown); } @@ -830,13 +830,13 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) // print_mstime uses a static buffer dbg_print(CCX_DMT_PARSE, "Stream #%d PacketTime: %s", - asf_data_container.PayloadStreamNumber, print_mstime(SendTime)); + asf_data_container.PayloadStreamNumber, print_mstime(send_time)); dbg_print(CCX_DMT_PARSE," PayloadTime: %s", - print_mstime(PresentationTimems)); + print_mstime(presentation_time_millis)); dbg_print(CCX_DMT_PARSE," dvr-ms PTS: %s+%lld\n", print_mstime(rtStart/10000), (rtEnd-rtStart)/10000); - datapacketlength+=ReplicatedLength; + data_packet_length+=replicated_length; // Only multiple payload packages have this value if (asf_data_container.MultiplePayloads != 0) @@ -856,21 +856,21 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) } else { - asf_data_container.PayloadLength = asf_data_container.PacketLength - datapacketlength - asf_data_container.PaddingLength; + asf_data_container.PayloadLength = asf_data_container.PacketLength - data_packet_length - asf_data_container.PaddingLength; } dbg_print(CCX_DMT_PARSE, "Size - Replicated %d + Payload %d = %d\n", - ReplicatedLength, asf_data_container.PayloadLength, ReplicatedLength + asf_data_container.PayloadLength); + replicated_length, asf_data_container.PayloadLength, replicated_length + asf_data_container.PayloadLength); // Remember the last video time stamp - only when captions are separate // from video stream. if (asf_data_container.PayloadStreamNumber == asf_data_container.StreamProperties.VideoStreamNumber && asf_data_container.StreamProperties.DecodeStreamNumber != asf_data_container.StreamProperties.VideoStreamNumber - && OffsetMediaLength == 0) + && offset_media_length == 0) { asf_data_container.StreamProperties.prevVideoStreamMS = asf_data_container.StreamProperties.currVideoStreamMS; asf_data_container.StreamProperties.currVideoStreamMS = asf_data_container.StreamProperties.VideoStreamMS; - // Use PresentationTimems (SendTime might also work) when the + // Use presentation_time_millis (send_time might also work) when the // dvr-ms time stamp is not present. if (asf_data_container.PayloadExtPTSEntry[asf_data_container.PayloadStreamNumber] > 0) { @@ -881,7 +881,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) else { // Add 1ms to avoid 0ms start times getting rejected - asf_data_container.StreamProperties.VideoStreamMS = PresentationTimems + 1; + asf_data_container.StreamProperties.VideoStreamMS = presentation_time_millis + 1; } // This checks if there is a video time jump in the timeline // between caption information. @@ -896,12 +896,12 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) // Remember the PTS values if (asf_data_container.PayloadStreamNumber == asf_data_container.StreamProperties.DecodeStreamNumber - && OffsetMediaLength == 0) + && offset_media_length == 0) { asf_data_container.StreamProperties.prevDecodeStreamPTS = asf_data_container.StreamProperties.currDecodeStreamPTS; asf_data_container.StreamProperties.currDecodeStreamPTS = asf_data_container.StreamProperties.DecodeStreamPTS; - // Use PresentationTimems (SendTime might also work) when the + // Use presentation_time_millis (send_time might also work) when the // dvr-ms time stamp is not present. if (asf_data_container.PayloadExtPTSEntry[asf_data_container.PayloadStreamNumber] > 0) { @@ -912,7 +912,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) else { // Add 1ms to avoid 0ms start times getting rejected - asf_data_container.StreamProperties.DecodeStreamPTS = PresentationTimems + 1; + asf_data_container.StreamProperties.DecodeStreamPTS = presentation_time_millis + 1; } // Check the caption stream for jumps in the timeline. This @@ -955,9 +955,9 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) // Video streams need several packages to complete a PES. Leave // the loop when the next package starts a new Media Object. - if ( curmedianumber != 0xFFFFFFFF // Is initialized + if ( current_media_number != 0xFFFFFFFF // Is initialized && asf_data_container.PayloadStreamNumber == asf_data_container.StreamProperties.DecodeStreamNumber - && asf_data_container.PayloadMediaNumber != curmedianumber) + && asf_data_container.PayloadMediaNumber != current_media_number) { if (asf_data_container.StreamProperties.DecodeStreamNumber == asf_data_container.StreamProperties.CaptionStreamNumber) dbg_print(CCX_DMT_PARSE, "\nCaption stream object"); @@ -975,7 +975,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) // Read it!! if (asf_data_container.PayloadStreamNumber == asf_data_container.StreamProperties.DecodeStreamNumber) { - curmedianumber = asf_data_container.PayloadMediaNumber; // Remember current value + current_media_number = asf_data_container.PayloadMediaNumber; // Remember current value // Read the data dbg_print(CCX_DMT_PARSE, "Reading Stream #%d data ...\n", asf_data_container.PayloadStreamNumber);