VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gvrtppacketstream.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file gvrtppacketstream.h
19 ///
20 
21 #ifndef GV_RTP_PACKET_STREAM__H
22 #define GV_RTP_PACKET_STREAM__H
23 
24 #include "gdef.h"
25 #include "gassert.h"
26 #include "gvrtppacket.h"
27 #include "gvrtpavcpacket.h"
28 #include "gvrtpjpegpacket.h"
29 #include <vector>
30 #include <deque>
31 
32 namespace Gv
33 {
34  class RtpPacketStream ;
35 } ;
36 
37 /// \class Gv::RtpPacketStream
38 /// A class that accumulates RTP-AVC or RTP-JPEG packets and serves
39 /// up AVC NALUs or JPEG JFIFs.
40 ///
41 /// Note that there is no one-to-one correspondence between RTP-AVC
42 /// packets and NALUs; NALUs can be fragmented over multiple
43 /// packets, and multiple NULUs can be aggregated into one packet.
44 /// JPEG images can also be fragmented over multiple packets.
45 ///
47 {
48 public:
49  explicit RtpPacketStream( int jpeg_fudge_factor ) ;
50  ///< Constructor.
51 
52  bool add( const RtpPacket & , const RtpAvcPacket & ) ;
53  ///< Adds a AVC packet.
54 
55  bool add( const RtpPacket & , const RtpJpegPacket & ) ;
56  ///< Adds a JPEG packet.
57 
58  bool more() const ;
59  ///< Returns true if NALUs or JFIFs are available.
60 
61  std::vector<char> get() ;
62  ///< Extracts a NALU or JFIF.
63 
64 private:
65  RtpPacketStream( const RtpPacketStream & ) ;
66  void operator=( const RtpPacketStream & ) ;
67  bool contiguous() const ;
68  void commit( const RtpAvcPacket & ) ;
69  void commit( const RtpJpegPacket & ) ;
70  void clear() ;
71 
72 private:
73  int m_jpeg_fudge_factor ;
74  unsigned long m_timestamp ;
75  std::vector<unsigned int> m_seq_list ;
76  std::vector<char> m_buffer ;
77  std::deque<std::vector<char> > m_list ;
78 } ;
79 
80 #endif
bool add(const RtpPacket &, const RtpAvcPacket &)
Adds a AVC packet.
An RTP payload parser for the jpeg payload type.
RtpPacketStream(int jpeg_fudge_factor)
Constructor.
A class that accumulates RTP-AVC or RTP-JPEG packets and serves up AVC NALUs or JPEG JFIFs...
An RTP packet parser, as per RFC 3550 (section 5).
Definition: gvrtppacket.h:44
bool more() const
Returns true if NALUs or JFIFs are available.
An RTP payload parser for the "H264" payload type.