// ------------------------------------- // Debugging functions // void QTAtom_mvhd::DumpAtom() { // Temporary vars time_t unixCreationTime = (time_t)fCreationTime + (time_t)QT_TIME_TO_LOCAL_TIME; char buffer[kTimeStrSize]; struct tm timeResult; DEBUG_PRINT(("QTAtom_mvhd::DumpAtom - Dumping atom.\n")); DEBUG_PRINT(("QTAtom_mvhd::DumpAtom - ..Version: %d.\n", (int)fVersion)); DEBUG_PRINT(("QTAtom_mvhd::DumpAtom - ..Creation date: %s", qtss_asctime(qtss_gmtime(&unixCreationTime, &timeResult), buffer, sizeof(buffer)))); DEBUG_PRINT(("QTAtom_mvhd::DumpAtom - ..Movie duration: %.2f seconds\n", GetDurationInSeconds())); }
// ------------------------------------- // Debugging functions // void QTAtom_tkhd::DumpAtom(void) { // Temporary vars time_t unixCreationTime = (time_t)fCreationTime + (time_t)QT_TIME_TO_LOCAL_TIME; char buffer[kTimeStrSize]; struct tm timeResult; DEBUG_PRINT(("QTAtom_tkhd::DumpAtom - Dumping atom.\n")); DEBUG_PRINT(("QTAtom_tkhd::DumpAtom - ..Version: %d.\n", (int) fVersion)); DEBUG_PRINT(("QTAtom_tkhd::DumpAtom - ..Track ID: %"_S32BITARG_"\n", fTrackID)); DEBUG_PRINT(("QTAtom_tkhd::DumpAtom - ..Flags:%s%s%s%s\n", (fFlags & flagEnabled) ? " Enabled" : "", (fFlags & flagInMovie) ? " InMovie" : "", (fFlags & flagInPreview) ? " InPreview" : "", (fFlags & flagInPoster) ? " InPoster" : "")); DEBUG_PRINT(("QTAtom_tkhd::DumpAtom - ..Creation date: %s", qtss_asctime(qtss_gmtime(&unixCreationTime, &timeResult),buffer,sizeof(buffer)))); }
int main(int argc, char *argv[]) { // Temporary vars int ch; UInt16 tempInt16; UInt32 tempInt32; Float32 tempFloat32; Float64 tempFloat64; // General vars int fd; const char *MovieFilename; int TrackNumber; QTTrack *Track; QTHintTrack *HintTrack; bool Debug = false, DeepDebug = false; UInt16 NumPackets; extern int optind; // // Read our command line options while( (ch = getopt(argc, argv, "dD")) != -1 ) { switch( ch ) { case 'd': Debug = true; break; case 'D': Debug = true; DeepDebug = true; break; } } argc -= optind; argv += optind; // // Validate our arguments. if( argc != 2 ) { qtss_printf("usage: QTRTPGen [-d] [-D] <filename> <track number>\n"); exit(1); } MovieFilename = *argv++; TrackNumber = atoi(*argv++); // // Open the movie. QTFile file(Debug, DeepDebug); file.Open(MovieFilename); // // Find the specified track and dump out information about its' samples. if( !file.FindTrack(TrackNumber, &Track) ) { qtss_printf("Error! Could not find track number %d in file \"%s\"!", TrackNumber, MovieFilename); exit(1); } // // Make sure that this is a hint track. if( !file.IsHintTrack(Track) ) { qtss_printf("Error! Track number %d is not a hint track!\n", TrackNumber); exit(1); } HintTrack = (QTHintTrack *)Track; // // Initialize this track. HintTrack->Initialize(); // // Dump some information about this track. { time_t unixCreationTime = (time_t)HintTrack->GetCreationTime() + (time_t)QT_TIME_TO_LOCAL_TIME; time_t unixModificationTime = (time_t)HintTrack->GetModificationTime() + (time_t)QT_TIME_TO_LOCAL_TIME; char buffer[kTimeStrSize]; struct tm timeResult; qtss_printf("-- Track #%02"_S32BITARG_" ---------------------------\n", HintTrack->GetTrackID()); qtss_printf(" Name : %s\n", HintTrack->GetTrackName()); qtss_printf(" Created on : %s", qtss_asctime(qtss_gmtime(&unixCreationTime, &timeResult),buffer, sizeof(buffer))); qtss_printf(" Modified on : %s", qtss_asctime(qtss_gmtime(&unixModificationTime, &timeResult),buffer, sizeof(buffer))); qtss_printf(" Total RTP bytes : %"_64BITARG_"u\n", HintTrack->GetTotalRTPBytes()); qtss_printf(" Total RTP packets : %"_64BITARG_"u\n", HintTrack->GetTotalRTPPackets()); qtss_printf(" Average bitrate : %.2f Kbps\n",(float) ((HintTrack->GetTotalRTPBytes() << 3) / file.GetDurationInSeconds()) / 1024); qtss_printf(" Average packet size: %"_64BITARG_"u\n", HintTrack->GetTotalRTPBytes() / HintTrack->GetTotalRTPPackets()); UInt32 UDPIPHeaderSize = (56 * HintTrack->GetTotalRTPPackets()); UInt32 RTPUDPIPHeaderSize = ((56+12) * HintTrack->GetTotalRTPPackets()); qtss_printf(" Percentage of stream wasted on UDP/IP headers : %.2f\n", (float)UDPIPHeaderSize / (float)(HintTrack->GetTotalRTPBytes() + UDPIPHeaderSize) * 100); qtss_printf(" Percentage of stream wasted on RTP/UDP/IP headers: %.2f\n", (float)RTPUDPIPHeaderSize / (float)(HintTrack->GetTotalRTPBytes() + RTPUDPIPHeaderSize) * 100); qtss_printf("\n"); qtss_printf("\n"); } // // Open our file to write the packets out to. fd = open("track.cache", O_CREAT | O_TRUNC | O_WRONLY, 0666); if( fd == -1 ) { qtss_printf("Error! Could not create output file!\n"); exit(1); } // // Write out the header. tempInt16 = 1; write(fd, (char *)&tempInt16, 2); // isCompletelyWritten tempInt16 = 0; write(fd, (char *)&tempInt16, 2); // padding1 tempFloat64 = file.GetDurationInSeconds(); write(fd, (char *)&tempFloat64, 8); // movieLength tempInt32 = HintTrack->GetRTPTimescale(); write(fd, (char *)&tempInt32, 4); // rtpTimescale tempInt16 = HintTrack->GetRTPSequenceNumberRandomOffset(); write(fd, (char *)&tempInt16, 2); // seqNumRandomOffset tempInt16 = 0; write(fd, (char *)&tempInt16, 2); // padding2 tempFloat32 = HintTrack->GetTotalRTPBytes() / file.GetDurationInSeconds(); write(fd, (char *)&tempFloat32, 4); // dataRate // // Go through all of the samples in this track, printing out their offsets // and sizes. qtss_printf("Sample # NPkts\n"); qtss_printf("-------- -----\n"); UInt32 curSample = 1; QTHintTrack_HintTrackControlBlock HCB; while( HintTrack->GetNumPackets(curSample, &NumPackets) == QTTrack::errNoError ) { // // Generate all of the packets. qtss_printf("Generating %u packet(s) in sample #%"_U32BITARG_"..\n", NumPackets, curSample); for( UInt16 curPacket = 1; curPacket <= NumPackets; curPacket++ ) { // General vars #define MAX_PACKET_LEN 2048 char Packet[MAX_PACKET_LEN]; UInt32 PacketLength; Float64 TransmitTime; // // Generate this packet. PacketLength = MAX_PACKET_LEN; HintTrack->GetPacket(curSample, curPacket, Packet, &PacketLength, &TransmitTime, false, false, 0,&HCB); // // Write out the packet header. write(fd, (char *)&TransmitTime, 8); // transmitTime tempInt16 = PacketLength; write(fd, (char *)&tempInt16, 2); // packetLength tempInt16 = 0; write(fd, (char *)&tempInt16, 2); // padding1 // // Write out the packet. write(fd, Packet, PacketLength); } // // Next sample. curSample++; } // // Close the output file. close(fd); return 0; }
void PLBroadcastDef::ShowSettings() { qtss_printf( "\n" ); qtss_printf( "Description File Settings\n" ); qtss_printf( "----------------------------\n" ); qtss_printf( "destination_ip_address %s\n", mOrigDestAddress ); qtss_printf( "destination_sdp_file %s\n", mDestSDPFile ); qtss_printf( "destination_base_port %s\n", mBasePort ); qtss_printf( "play_mode %s\n", mPlayMode ); qtss_printf( "recent_movies_list_size %d\n", mLimitPlayQueueLength ); qtss_printf( "playlist_file %s\n", mPlayListFile ); qtss_printf( "logging %s\n", mLogging ); qtss_printf( "log_file %s\n", mLogFile ); if (mSDPReferenceMovie != NULL) qtss_printf( "sdp_reference_movie %s\n", mSDPReferenceMovie ); qtss_printf( "sdp_file %s\n", mSDPFile ); qtss_printf( "max_upcoming_list_size %s\n", mMaxUpcomingMovieListSize ); qtss_printf( "show_current %s\n", mShowCurrent ); qtss_printf( "show_upcoming %s\n", mShowUpcoming ); qtss_printf( "broadcaster_name \"%s\"\n", mName); qtss_printf( "broadcaster_password \"XXXXX\"\n"); qtss_printf( "multicast_ttl %s\n",mTTL); qtss_printf( "rtsp_port %s\n",mRTSPPort); Float32 bufferDelay = 0.0; ::sscanf(mClientBufferDelay, "%f", &bufferDelay); if (bufferDelay != 0.0) qtss_printf( "client_buffer_delay %.2f\n",bufferDelay); else qtss_printf( "client_buffer_delay default\n"); if (mPIDFile != NULL) qtss_printf( "pid_file %s\n",mPIDFile); qtss_printf( "broadcast_SDP_is_dynamic %s\n", mIsDynamic ); UInt32 startTime = (UInt32) ::strtoul(mStartTime, NULL, 10); if ( startTime > 2208988800LU) { qtss_printf( "broadcast_start_time %s (NTP seconds)\n",mStartTime); startTime -= 2208988800LU; //1970 - 1900 secs qtss_printf( "-->broadcast_start_time = %lu (unix seconds)\n",startTime); time_t tmpTime; tmpTime = (time_t) startTime; struct tm timeResult; struct tm *localTM = qtss_localtime(&tmpTime, &timeResult); char timeBuffer[kTimeStrSize]; char *theTime = qtss_asctime(localTM,timeBuffer, sizeof(timeBuffer)); if (theTime[0] != 0) theTime[::strlen(theTime) -1] = 0; qtss_printf( "-->broadcast_start_time = %s (local time)\n",theTime); tmpTime = (time_t) startTime; struct tm *gmTM = qtss_gmtime(&tmpTime, &timeResult); theTime = qtss_asctime(gmTM, timeBuffer, sizeof(timeBuffer)); if (theTime[0] != 0) theTime[::strlen(theTime) -1] = 0; qtss_printf( "-->broadcast_start_time = %s (UTC/GM time)\n",theTime); } else if (0 == startTime) qtss_printf( "broadcast_start_time 0 (allow all)\n"); else qtss_printf( "broadcast_start_time %s (NTPseconds allow all)\n", mStartTime); UInt32 endTime = strtoul(mEndTime, NULL, 10); if (endTime > 2208988800LU) { qtss_printf( "broadcast_end_time %s (NTP seconds)\n",mEndTime); endTime -= 2208988800LU;//convert to 1970 secs qtss_printf( "-->broadcast_end_time = %lu (unix seconds)\n",endTime); time_t tmpTime = (time_t) endTime; struct tm timeResult; struct tm *localTM = qtss_localtime(&tmpTime, &timeResult); char timeBuffer[kTimeStrSize]; char *theTime = qtss_asctime(localTM,timeBuffer, sizeof(timeBuffer)); if (theTime[0] != 0) theTime[::strlen(theTime) -1] = 0; qtss_printf( "-->broadcast_end_time = %s (local time)\n",theTime); tmpTime = (time_t) endTime; struct tm *gmTM = qtss_gmtime(&tmpTime, &timeResult); theTime = qtss_asctime(gmTM, timeBuffer, sizeof(timeBuffer)); if (theTime[0] != 0) theTime[::strlen(theTime) -1] = 0; qtss_printf( "-->broadcast_end_time = %s (UTC/GM time)\n",theTime); } else if (0 == endTime) qtss_printf( "broadcast_end_time 0 (unbounded)\n"); else qtss_printf( "broadcast_end_time 1900 + %s seconds (looks invalid)\n", mEndTime); qtss_printf( "max_err_file_k_size %lu\n", qtss_getmaxprintfcharsinK()); qtss_printf( "============================\n" ); }