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

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

Issue 2871173008: Fix packetization logic to leave space for extensions in the last packet (Closed)
Patch Set: Implement 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 10
(...skipping 15 matching lines...) Expand all
26 26
27 #include "webrtc/base/constructormagic.h" 27 #include "webrtc/base/constructormagic.h"
28 #include "webrtc/modules/include/module_common_types.h" 28 #include "webrtc/modules/include/module_common_types.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
30 #include "webrtc/typedefs.h" 30 #include "webrtc/typedefs.h"
31 31
32 namespace webrtc { 32 namespace webrtc {
33 33
34 class RtpPacketizerVp9 : public RtpPacketizer { 34 class RtpPacketizerVp9 : public RtpPacketizer {
35 public: 35 public:
36 RtpPacketizerVp9(const RTPVideoHeaderVP9& hdr, size_t max_payload_length); 36 RtpPacketizerVp9(const RTPVideoHeaderVP9& hdr,
37 size_t max_payload_length,
38 size_t last_packet_reduction_len);
37 39
38 virtual ~RtpPacketizerVp9(); 40 virtual ~RtpPacketizerVp9();
39 41
40 ProtectionType GetProtectionType() override; 42 ProtectionType GetProtectionType() override;
41 43
42 StorageType GetStorageType(uint32_t retransmission_settings) override; 44 StorageType GetStorageType(uint32_t retransmission_settings) override;
43 45
44 std::string ToString() override; 46 std::string ToString() override;
45 47
46 // The payload data must be one encoded VP9 frame. 48 // The payload data must be one encoded VP9 layer frame.
47 void SetPayloadData(const uint8_t* payload, 49 size_t SetPayloadData(const uint8_t* payload,
48 size_t payload_size, 50 size_t payload_size,
49 const RTPFragmentationHeader* fragmentation) override; 51 const RTPFragmentationHeader* fragmentation) override;
50 52
51 // Gets the next payload with VP9 payload header. 53 // Gets the next payload with VP9 payload header.
52 // Write payload and set marker bit of the |packet|. 54 // Write payload and set marker bit of the |packet|.
53 // The parameter |last_packet| is true for the last packet of the frame, false
54 // otherwise (i.e., call the function again to get the next packet).
55 // Returns true on success, false otherwise. 55 // Returns true on success, false otherwise.
56 bool NextPacket(RtpPacketToSend* packet, bool* last_packet) override; 56 bool NextPacket(RtpPacketToSend* packet) override;
57 57
58 typedef struct { 58 typedef struct {
59 size_t payload_start_pos; 59 size_t payload_start_pos;
60 size_t size; 60 size_t size;
61 bool layer_begin; 61 bool layer_begin;
62 bool layer_end; 62 bool layer_end;
63 } PacketInfo; 63 } PacketInfo;
64 typedef std::queue<PacketInfo> PacketInfoQueue; 64 typedef std::queue<PacketInfo> PacketInfoQueue;
65 65
66 private: 66 private:
67 // Calculates all packet sizes and loads info to packet queue. 67 // Calculates all packet sizes and loads info to packet queue.
68 void GeneratePackets(); 68 void GeneratePackets();
69 69
70 // Writes the payload descriptor header and copies payload to the |buffer|. 70 // Writes the payload descriptor header and copies payload to the |buffer|.
71 // |packet_info| determines which part of the payload to write. 71 // |packet_info| determines which part of the payload to write.
72 // |bytes_to_send| contains the number of written bytes to the buffer. 72 // |last| indicates if the packet is last.
danilchap 2017/05/23 15:55:03 probably drop the: 'if packet is last' may be add
ilnik 2017/05/23 16:14:30 Done.
73 // Returns true on success, false otherwise. 73 // Returns true on success, false otherwise.
74 bool WriteHeaderAndPayload(const PacketInfo& packet_info, 74 bool WriteHeaderAndPayload(const PacketInfo& packet_info,
75 RtpPacketToSend* packet) const; 75 RtpPacketToSend* packet,
76 bool last) const;
76 77
77 // Writes payload descriptor header to |buffer|. 78 // Writes payload descriptor header to |buffer|.
78 // Returns true on success, false otherwise. 79 // Returns true on success, false otherwise.
79 bool WriteHeader(const PacketInfo& packet_info, 80 bool WriteHeader(const PacketInfo& packet_info,
80 uint8_t* buffer, 81 uint8_t* buffer,
81 size_t* header_length) const; 82 size_t* header_length) const;
82 83
83 const RTPVideoHeaderVP9 hdr_; 84 const RTPVideoHeaderVP9 hdr_;
84 const size_t max_payload_length_; // The max length in bytes of one packet. 85 const size_t max_payload_length_; // The max length in bytes of one packet.
85 const uint8_t* payload_; // The payload data to be packetized. 86 const uint8_t* payload_; // The payload data to be packetized.
86 size_t payload_size_; // The size in bytes of the payload data. 87 size_t payload_size_; // The size in bytes of the payload data.
88 const size_t last_packet_reduction_len_;
87 PacketInfoQueue packets_; 89 PacketInfoQueue packets_;
88 90
89 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); 91 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9);
90 }; 92 };
91 93
92 94
93 class RtpDepacketizerVp9 : public RtpDepacketizer { 95 class RtpDepacketizerVp9 : public RtpDepacketizer {
94 public: 96 public:
95 virtual ~RtpDepacketizerVp9() {} 97 virtual ~RtpDepacketizerVp9() {}
96 98
97 bool Parse(ParsedPayload* parsed_payload, 99 bool Parse(ParsedPayload* parsed_payload,
98 const uint8_t* payload, 100 const uint8_t* payload,
99 size_t payload_length) override; 101 size_t payload_length) override;
100 }; 102 };
101 103
102 } // namespace webrtc 104 } // namespace webrtc
103 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ 105 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698