00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "DVVideoRTPSink.hh"
00023
00025
00026 DVVideoRTPSink
00027 ::DVVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat)
00028 : VideoRTPSink(env, RTPgs, rtpPayloadFormat, 90000, "DV"),
00029 fFmtpSDPLine(NULL) {
00030 }
00031
00032 DVVideoRTPSink::~DVVideoRTPSink() {
00033 delete[] fFmtpSDPLine;
00034 }
00035
00036 DVVideoRTPSink*
00037 DVVideoRTPSink::createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat) {
00038 return new DVVideoRTPSink(env, RTPgs, rtpPayloadFormat);
00039 }
00040
00041 Boolean DVVideoRTPSink::sourceIsCompatibleWithUs(MediaSource& source) {
00042
00043 return source.isDVVideoStreamFramer();
00044 }
00045
00046 void DVVideoRTPSink::doSpecialFrameHandling(unsigned fragmentationOffset,
00047 unsigned char* ,
00048 unsigned ,
00049 struct timeval framePresentationTime,
00050 unsigned numRemainingBytes) {
00051 if (numRemainingBytes == 0) {
00052
00053
00054 setMarkerBit();
00055 }
00056
00057
00058 setTimestamp(framePresentationTime);
00059 }
00060
00061 unsigned DVVideoRTPSink::computeOverflowForNewFrame(unsigned newFrameSize) const {
00062 unsigned initialOverflow = MultiFramedRTPSink::computeOverflowForNewFrame(newFrameSize);
00063
00064
00065
00066 unsigned numFrameBytesUsed = newFrameSize - initialOverflow;
00067 initialOverflow += numFrameBytesUsed%DV_DIF_BLOCK_SIZE;
00068
00069 return initialOverflow;
00070 }
00071
00072 char const* DVVideoRTPSink::auxSDPLine() {
00073
00074
00075
00076 DVVideoStreamFramer* framerSource = (DVVideoStreamFramer*)fSource;
00077 if (framerSource == NULL) return NULL;
00078
00079 return auxSDPLineFromFramer(framerSource);
00080 }
00081
00082 char const* DVVideoRTPSink::auxSDPLineFromFramer(DVVideoStreamFramer* framerSource) {
00083 char const* const profileName = framerSource->profileName();
00084 if (profileName == NULL) return NULL;
00085
00086 char const* const fmtpSDPFmt = "a=fmtp:%d encode=%s;audio=bundled\r\n";
00087 unsigned fmtpSDPFmtSize = strlen(fmtpSDPFmt)
00088 + 3
00089 + strlen(profileName);
00090 delete[] fFmtpSDPLine;
00091 fFmtpSDPLine = new char[fmtpSDPFmtSize];
00092 sprintf(fFmtpSDPLine, fmtpSDPFmt, rtpPayloadType(), profileName);
00093
00094 return fFmtpSDPLine;
00095 }