31 m_jpeg_fudge_factor(jpeg_fudge_factor) ,
38 const size_t fragment_offset = jpeg_packet.
fo() ;
39 const bool last_fragment = rtp_packet.
marker() ;
40 const bool first_fragment = fragment_offset == 0U ;
41 const bool is_single = first_fragment && last_fragment ;
48 m_seq_list.push_back( rtp_packet.
seq() ) ;
49 commit( jpeg_packet ) ;
59 m_seq_list.push_back( rtp_packet.
seq() ) ;
62 else if( rtp_packet.
timestamp() != m_timestamp || fragment_offset != m_buffer.size() )
64 G_WARNING(
"Gv::RtpServer::processRtpJpegPacket: ignoring out-of-sequence packet: " << rtp_packet.
str() ) ;
71 m_seq_list.push_back( rtp_packet.
seq() ) ;
76 commit( jpeg_packet ) ;
82 G_WARNING(
"Gv::RtpServer::processRtpJpegPacket: ignoring frame with missing packets" ) ;
100 commit( avc_packet ) ;
111 m_seq_list.push_back( rtp_packet.
seq() ) ;
114 else if( rtp_packet.
timestamp() != m_timestamp )
116 G_WARNING(
"Gv::RtpServer::processRtpAvcPacket: ignoring out-of-sequence packet: " << rtp_packet.
str() ) ;
122 size_t pos = m_buffer.size() ;
125 m_seq_list.push_back( rtp_packet.
seq() ) ;
130 commit( avc_packet ) ;
136 G_WARNING(
"Gv::RtpServer::processRtpAvcPacket: ignoring frame with missing packets" ) ;
145 G_WARNING(
"Gv::RtpServer::processRtpAvcPacket: ignoring rtp-avc aggregation packet: not implemented" ) ;
151 bool Gv::RtpPacketStream::contiguous()
const
153 unsigned int old = 0U ;
156 for( std::vector<unsigned int>::const_iterator p = m_seq_list.begin() ; ok && p != m_seq_list.end() ; ++p , first = false )
158 ok = first || *p == (old+1U) || ( *p == 0U && old != 0U ) ;
164 void Gv::RtpPacketStream::commit(
const RtpJpegPacket & jpeg_packet )
168 m_buffer.push_back( 0xff ) ;
169 m_buffer.push_back( 0xd9 ) ;
171 m_list.push_back( std::vector<char>() ) ;
172 m_buffer.swap( m_list.back() ) ;
173 G_ASSERT( m_buffer.empty() ) ;
176 void Gv::RtpPacketStream::commit(
const RtpAvcPacket & )
180 m_buffer.insert( m_buffer.begin() , start_code.begin() , start_code.end() ) ;
182 m_list.push_back( std::vector<char>() ) ;
183 m_buffer.swap( m_list.back() ) ;
184 G_ASSERT( m_buffer.empty() ) ;
187 void Gv::RtpPacketStream::clear()
196 return !m_list.empty() ;
201 G_ASSERT( !m_list.empty() ) ;
202 std::vector<char> result = m_list.front() ;
const char * payloadBegin() const
Returns the RTP-AVC payload pointer, but the first byte may be wrong so use payloadFirst() to overwri...
bool add(const RtpPacket &, const RtpAvcPacket &)
Adds a AVC packet.
An RTP payload parser for the jpeg payload type.
unsigned long fo() const
Returns the fragment offset.
std::string str() const
Returns a one-line summary of header fields.
bool type_is_single() const
Returns true if type() is SINGLE_NALU_x.
bool fu_start() const
Returns true for the first FU packet in the fragmented NALU.
static iterator_t generateHeader(iterator_t out, const RtpJpegPacket &, int fudge=0)
Generates the start of a JFIF buffer; the rest of the JFIF buffer is a simple copy of all the payload...
const char * payloadEnd() const
Returns the RTP-AVC payload end pointer.
RtpPacketStream(int jpeg_fudge_factor)
Constructor.
const char * payloadBegin() const
Returns payload().begin.
const char * payloadEnd() const
Returns payload().end.
An RTP packet parser, as per RFC 3550 (section 5).
bool more() const
Returns true if NALUs or JFIFs are available.
std::vector< char > get()
Extracts a NALU or JFIF.
unsigned long timestamp() const
Returns the timestamp.
An RTP payload parser for the "H264" payload type.
char payloadFirst() const
Returns the first RTP-AVC payload byte.
unsigned int seq() const
Returns the sequence number.
bool marker() const
Returns the marker bit.
bool type_is_fu() const
Returns true if type() is FU_A or FU_B.
bool fu_end() const
Returns true for the last FU packet in the fragmented NALU.
static const std::string & _0001()
Returns the 00-00-00-01 string.