1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ 11 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ 12 13 #include "webrtc/common_types.h" 14 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" 15 #include "webrtc/typedefs.h" 16 17 namespace webrtc { 18 namespace RtpFormatVideoGeneric { 19 static const uint8_t kKeyFrameBit = 0x01; 20 static const uint8_t kFirstPacketBit = 0x02; 21 } // namespace RtpFormatVideoGeneric 22 23 class RtpPacketizerGeneric : public RtpPacketizer { 24 public: 25 // Initialize with payload from encoder. 26 // The payload_data must be exactly one encoded generic frame. 27 RtpPacketizerGeneric(FrameType frametype, size_t max_payload_len); 28 29 virtual ~RtpPacketizerGeneric(); 30 31 virtual void SetPayloadData( 32 const uint8_t* payload_data, 33 size_t payload_size, 34 const RTPFragmentationHeader* fragmentation) OVERRIDE; 35 36 // Get the next payload with generic payload header. 37 // buffer is a pointer to where the output will be written. 38 // bytes_to_send is an output variable that will contain number of bytes 39 // written to buffer. The parameter last_packet is true for the last packet of 40 // the frame, false otherwise (i.e., call the function again to get the 41 // next packet). 42 // Returns true on success or false if there was no payload to packetize. 43 virtual bool NextPacket(uint8_t* buffer, 44 size_t* bytes_to_send, 45 bool* last_packet) OVERRIDE; 46 47 virtual ProtectionType GetProtectionType() OVERRIDE; 48 49 virtual StorageType GetStorageType(uint32_t retransmission_settings) OVERRIDE; 50 51 virtual std::string ToString() OVERRIDE; 52 53 private: 54 const uint8_t* payload_data_; 55 size_t payload_size_; 56 const size_t max_payload_len_; 57 FrameType frame_type_; 58 uint32_t payload_length_; 59 uint8_t generic_header_; 60 61 DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric); 62 }; 63 64 // Depacketizer for generic codec. 65 class RtpDepacketizerGeneric : public RtpDepacketizer { 66 public: 67 explicit RtpDepacketizerGeneric(RtpData* const callback); 68 ~RtpDepacketizerGeneric()69 virtual ~RtpDepacketizerGeneric() {} 70 71 virtual bool Parse(WebRtcRTPHeader* rtp_header, 72 const uint8_t* payload_data, 73 size_t payload_data_length) OVERRIDE; 74 75 private: 76 RtpData* const callback_; 77 78 DISALLOW_COPY_AND_ASSIGN(RtpDepacketizerGeneric); 79 }; 80 } // namespace webrtc 81 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ 82