Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h

Issue 2871173008: Fix packetization logic to leave space for extensions in the last packet (Closed)
Patch Set: Impelement Danilchap@ comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
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_reduction_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_reduction_len_;
55 FrameType frame_type_; 57 FrameType frame_type_;
56 size_t payload_length_; 58 size_t payload_len_per_packet_;
57 uint8_t generic_header_; 59 uint8_t generic_header_;
60 // Number of packets yet to be retrieved by NextPacket() call.
61 size_t num_packets_left_;
62 // Number of packets, which will be 1 byte more than the rest.
63 size_t num_larger_packets_;
58 64
59 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric); 65 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric);
60 }; 66 };
61 67
62 // Depacketizer for generic codec. 68 // Depacketizer for generic codec.
63 class RtpDepacketizerGeneric : public RtpDepacketizer { 69 class RtpDepacketizerGeneric : public RtpDepacketizer {
64 public: 70 public:
65 virtual ~RtpDepacketizerGeneric() {} 71 virtual ~RtpDepacketizerGeneric() {}
66 72
67 bool Parse(ParsedPayload* parsed_payload, 73 bool Parse(ParsedPayload* parsed_payload,
68 const uint8_t* payload_data, 74 const uint8_t* payload_data,
69 size_t payload_data_length) override; 75 size_t payload_data_length) override;
70 }; 76 };
71 } // namespace webrtc 77 } // namespace webrtc
72 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_ 78 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VIDEO_GENERIC_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698