OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 StorageType GetStorageType(uint32_t retransmission_settings) override; | 42 StorageType GetStorageType(uint32_t retransmission_settings) override; |
43 | 43 |
44 std::string ToString() override; | 44 std::string ToString() override; |
45 | 45 |
46 // The payload data must be one encoded VP9 frame. | 46 // The payload data must be one encoded VP9 frame. |
47 void SetPayloadData(const uint8_t* payload, | 47 void SetPayloadData(const uint8_t* payload, |
48 size_t payload_size, | 48 size_t payload_size, |
49 const RTPFragmentationHeader* fragmentation) override; | 49 const RTPFragmentationHeader* fragmentation) override; |
50 | 50 |
51 // Gets the next payload with VP9 payload header. | 51 // Gets the next payload with VP9 payload header. |
52 // |buffer| is a pointer to where the output will be written. | 52 // Write payload and set marker bit of the |packet|. |
53 // |bytes_to_send| is an output variable that will contain number of bytes | 53 // The parameter |last_packet| is true for the last packet of the frame, false |
54 // written to buffer. | 54 // otherwise (i.e., call the function again to get the next packet). |
55 // |last_packet| is true for the last packet of the frame, false otherwise | |
56 // (i.e. call the function again to get the next packet). | |
57 // Returns true on success, false otherwise. | 55 // Returns true on success, false otherwise. |
58 bool NextPacket(uint8_t* buffer, | 56 bool NextPacket(RtpPacketToSend* packet, bool* last_packet) override; |
59 size_t* bytes_to_send, | |
60 bool* last_packet) override; | |
61 | 57 |
62 typedef struct { | 58 typedef struct { |
63 size_t payload_start_pos; | 59 size_t payload_start_pos; |
64 size_t size; | 60 size_t size; |
65 bool layer_begin; | 61 bool layer_begin; |
66 bool layer_end; | 62 bool layer_end; |
67 } PacketInfo; | 63 } PacketInfo; |
68 typedef std::queue<PacketInfo> PacketInfoQueue; | 64 typedef std::queue<PacketInfo> PacketInfoQueue; |
69 | 65 |
70 private: | 66 private: |
71 // Calculates all packet sizes and loads info to packet queue. | 67 // Calculates all packet sizes and loads info to packet queue. |
72 void GeneratePackets(); | 68 void GeneratePackets(); |
73 | 69 |
74 // Writes the payload descriptor header and copies payload to the |buffer|. | 70 // Writes the payload descriptor header and copies payload to the |buffer|. |
75 // |packet_info| determines which part of the payload to write. | 71 // |packet_info| determines which part of the payload to write. |
76 // |bytes_to_send| contains the number of written bytes to the buffer. | 72 // |bytes_to_send| contains the number of written bytes to the buffer. |
77 // Returns true on success, false otherwise. | 73 // Returns true on success, false otherwise. |
78 bool WriteHeaderAndPayload(const PacketInfo& packet_info, | 74 bool WriteHeaderAndPayload(const PacketInfo& packet_info, |
79 uint8_t* buffer, | 75 RtpPacketToSend* packet) const; |
80 size_t* bytes_to_send) const; | |
81 | 76 |
82 // Writes payload descriptor header to |buffer|. | 77 // Writes payload descriptor header to |buffer|. |
83 // Returns true on success, false otherwise. | 78 // Returns true on success, false otherwise. |
84 bool WriteHeader(const PacketInfo& packet_info, | 79 bool WriteHeader(const PacketInfo& packet_info, |
85 uint8_t* buffer, | 80 uint8_t* buffer, |
86 size_t* header_length) const; | 81 size_t* header_length) const; |
87 | 82 |
88 const RTPVideoHeaderVP9 hdr_; | 83 const RTPVideoHeaderVP9 hdr_; |
89 const size_t max_payload_length_; // The max length in bytes of one packet. | 84 const size_t max_payload_length_; // The max length in bytes of one packet. |
90 const uint8_t* payload_; // The payload data to be packetized. | 85 const uint8_t* payload_; // The payload data to be packetized. |
91 size_t payload_size_; // The size in bytes of the payload data. | 86 size_t payload_size_; // The size in bytes of the payload data. |
92 PacketInfoQueue packets_; | 87 PacketInfoQueue packets_; |
93 | 88 |
94 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); | 89 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); |
95 }; | 90 }; |
96 | 91 |
97 | 92 |
98 class RtpDepacketizerVp9 : public RtpDepacketizer { | 93 class RtpDepacketizerVp9 : public RtpDepacketizer { |
99 public: | 94 public: |
100 virtual ~RtpDepacketizerVp9() {} | 95 virtual ~RtpDepacketizerVp9() {} |
101 | 96 |
102 bool Parse(ParsedPayload* parsed_payload, | 97 bool Parse(ParsedPayload* parsed_payload, |
103 const uint8_t* payload, | 98 const uint8_t* payload, |
104 size_t payload_length) override; | 99 size_t payload_length) override; |
105 }; | 100 }; |
106 | 101 |
107 } // namespace webrtc | 102 } // namespace webrtc |
108 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ | 103 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ |
OLD | NEW |