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 <string> 14 15 #include "webrtc/common_types.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" 17 #include "webrtc/typedefs.h" 18 19 namespace webrtc { 20 namespace RtpFormatVideoGeneric { 21 static const uint8_t kKeyFrameBit = 0x01; 22 static const uint8_t kFirstPacketBit = 0x02; 23 } // namespace RtpFormatVideoGeneric 24 25 class RtpPacketizerGeneric : public RtpPacketizer { 26 public: 27 // Initialize with payload from encoder. 28 // The payload_data must be exactly one encoded generic frame. 29 RtpPacketizerGeneric(FrameType frametype, size_t max_payload_len); 30 31 virtual ~RtpPacketizerGeneric(); 32 33 void SetPayloadData(const uint8_t* payload_data, 34 size_t payload_size, 35 const RTPFragmentationHeader* fragmentation) override; 36 37 // Get the next payload with generic payload header. 38 // buffer is a pointer to where the output will be written. 39 // bytes_to_send is an output variable that will contain number of bytes 40 // written to buffer. The parameter last_packet is true for the last packet of 41 // the frame, false otherwise (i.e., call the function again to get the 42 // next packet). 43 // Returns true on success or false if there was no payload to packetize. 44 bool NextPacket(uint8_t* buffer, 45 size_t* bytes_to_send, 46 bool* last_packet) override; 47 48 ProtectionType GetProtectionType() override; 49 50 StorageType GetStorageType(uint32_t retransmission_settings) override; 51 52 std::string ToString() override; 53 54 private: 55 const uint8_t* payload_data_; 56 size_t payload_size_; 57 const size_t max_payload_len_; 58 FrameType frame_type_; 59 size_t payload_length_; 60 uint8_t generic_header_; 61 62 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric); 63 }; 64 65 // Depacketizer for generic codec. 66 class RtpDepacketizerGeneric : public RtpDepacketizer { 67 public: ~RtpDepacketizerGeneric()68 virtual ~RtpDepacketizerGeneric() {} 69 70 bool Parse(ParsedPayload* parsed_payload, 71 const uint8_t* payload_data, 72 size_t payload_data_length) override; 73 }; 74 } // namespace webrtc 75 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ 76