OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ | 10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ |
11 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ | 11 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "webrtc/base/constructormagic.h" | 15 #include "webrtc/base/constructormagic.h" |
16 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
17 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" |
18 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 namespace RtpFormatVideoGeneric { | 21 namespace RtpFormatVideoGeneric { |
22 static const uint8_t kKeyFrameBit = 0x01; | 22 static const uint8_t kKeyFrameBit = 0x01; |
23 static const uint8_t kFirstPacketBit = 0x02; | 23 static const uint8_t kFirstPacketBit = 0x02; |
24 } // namespace RtpFormatVideoGeneric | 24 } // namespace RtpFormatVideoGeneric |
25 | 25 |
26 class RtpPacketizerGeneric : public RtpPacketizer { | 26 class RtpPacketizerGeneric : public RtpPacketizer { |
danilchap
2017/05/12 13:56:10
It is likely good idea to add some tests,
speciall
ilnik
2017/05/12 14:46:08
Yes, will add them later. However, this generic pa
| |
27 public: | 27 public: |
28 // Initialize with payload from encoder. | 28 // Initialize with payload from encoder. |
29 // The payload_data must be exactly one encoded generic frame. | 29 // The payload_data must be exactly one encoded generic frame. |
30 RtpPacketizerGeneric(FrameType frametype, size_t max_payload_len); | 30 RtpPacketizerGeneric(FrameType frametype, |
31 size_t max_payload_len, | |
32 size_t last_packet_extension_len); | |
31 | 33 |
32 virtual ~RtpPacketizerGeneric(); | 34 virtual ~RtpPacketizerGeneric(); |
33 | 35 |
34 void SetPayloadData(const uint8_t* payload_data, | 36 // Returns total number of packets to be generated. |
35 size_t payload_size, | 37 size_t SetPayloadData(const uint8_t* payload_data, |
36 const RTPFragmentationHeader* fragmentation) override; | 38 size_t payload_size, |
39 const RTPFragmentationHeader* fragmentation) override; | |
37 | 40 |
38 // Get the next payload with generic payload header. | 41 // Get the next payload with generic payload header. |
39 // Write payload and set marker bit of the |packet|. | 42 // 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 // Returns true on success, false otherwise. |
43 bool NextPacket(RtpPacketToSend* packet, bool* last_packet) override; | 44 bool NextPacket(RtpPacketToSend* packet) override; |
44 | 45 |
45 ProtectionType GetProtectionType() override; | 46 ProtectionType GetProtectionType() override; |
46 | 47 |
47 StorageType GetStorageType(uint32_t retransmission_settings) override; | 48 StorageType GetStorageType(uint32_t retransmission_settings) override; |
48 | 49 |
49 std::string ToString() override; | 50 std::string ToString() override; |
50 | 51 |
51 private: | 52 private: |
52 const uint8_t* payload_data_; | 53 const uint8_t* payload_data_; |
53 size_t payload_size_; | 54 size_t payload_size_; |
54 const size_t max_payload_len_; | 55 const size_t max_payload_len_; |
56 const size_t last_packet_extension_len_; | |
55 FrameType frame_type_; | 57 FrameType frame_type_; |
56 size_t payload_length_; | 58 size_t payload_per_packet_; |
danilchap
2017/05/12 13:56:10
payload_length_per_packet_?
ilnik
2017/05/12 14:46:08
Done.
| |
57 uint8_t generic_header_; | 59 uint8_t generic_header_; |
60 size_t num_packets_; | |
danilchap
2017/05/12 13:56:10
Likely this member deserve a comment:
it is not ob
ilnik
2017/05/12 14:46:08
Changed to num_packets_left_. Now it's clear that
| |
61 size_t smaller_packets_; | |
danilchap
2017/05/12 13:56:10
can you add comment what this member is for?
https
ilnik
2017/05/12 14:46:08
Done.
| |
58 | 62 |
59 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric); | 63 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric); |
60 }; | 64 }; |
61 | 65 |
62 // Depacketizer for generic codec. | 66 // Depacketizer for generic codec. |
63 class RtpDepacketizerGeneric : public RtpDepacketizer { | 67 class RtpDepacketizerGeneric : public RtpDepacketizer { |
64 public: | 68 public: |
65 virtual ~RtpDepacketizerGeneric() {} | 69 virtual ~RtpDepacketizerGeneric() {} |
66 | 70 |
67 bool Parse(ParsedPayload* parsed_payload, | 71 bool Parse(ParsedPayload* parsed_payload, |
68 const uint8_t* payload_data, | 72 const uint8_t* payload_data, |
69 size_t payload_data_length) override; | 73 size_t payload_data_length) override; |
70 }; | 74 }; |
71 } // namespace webrtc | 75 } // namespace webrtc |
72 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ | 76 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ |
OLD | NEW |