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