OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 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 | |
11 /* | |
12 * This file contains the declaration of the VP9 packetizer class. | |
13 * A packetizer object is created for each encoded video frame. The | |
14 * constructor is called with the payload data and size. | |
15 * | |
16 * After creating the packetizer, the method NextPacket is called | |
17 * repeatedly to get all packets for the frame. The method returns | |
18 * false as long as there are more packets left to fetch. | |
19 */ | |
stefan-webrtc
2015/07/14 09:40:10
Make this a regular comment using //
åsapersson
2015/07/14 10:53:55
Done.
| |
20 | |
21 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ | |
22 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ | |
23 | |
24 #include <queue> | |
25 #include <string> | |
26 | |
27 #include "webrtc/base/constructormagic.h" | |
28 #include "webrtc/modules/interface/module_common_types.h" | |
29 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" | |
30 #include "webrtc/typedefs.h" | |
31 | |
32 namespace webrtc { | |
33 | |
34 class RtpPacketizerVp9 : public RtpPacketizer { | |
35 public: | |
36 RtpPacketizerVp9(const RTPVideoHeaderVP9& hdr, size_t max_payload_length); | |
37 | |
38 virtual ~RtpPacketizerVp9(); | |
39 | |
40 ProtectionType GetProtectionType() override; | |
41 | |
42 StorageType GetStorageType(uint32_t retransmission_settings) override; | |
43 | |
44 std::string ToString() override; | |
45 | |
46 // The payload data must be one encoded VP9 frame. | |
47 void SetPayloadData(const uint8_t* payload, | |
48 size_t payload_size, | |
49 const RTPFragmentationHeader* fragmentation) override; | |
50 | |
51 // Gets the next payload with VP9 payload header. | |
52 // |buffer| is a pointer to where the output will be written. | |
53 // |bytes_to_send| is an output variable that will contain number of bytes | |
54 // written to buffer. | |
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. | |
58 bool NextPacket(uint8_t* buffer, | |
59 size_t* bytes_to_send, | |
60 bool* last_packet) override; | |
61 | |
62 typedef struct { | |
63 size_t payload_start_pos; | |
64 size_t size; | |
65 bool layer_begin; | |
66 bool layer_end; | |
67 } PacketInfo; | |
68 typedef std::queue<PacketInfo> PacketInfoQueue; | |
69 | |
70 private: | |
71 // Calculates all packet sizes and loads info to packet queue. | |
72 void GeneratePackets(); | |
73 | |
74 // Writes the payload descriptor header and copies payload to the |buffer|. | |
75 // |packet_info| determines which part of the payload to write. | |
76 // |bytes_to_send| contains the number of written bytes to the buffer. | |
77 // Returns true on success, false otherwise. | |
78 bool WriteHeaderAndPayload(const PacketInfo& packet_info, | |
79 uint8_t* buffer, | |
80 size_t* bytes_to_send) const; | |
81 | |
82 // Writes payload descriptor header to |buffer|. | |
83 // Returns true on success, false otherwise. | |
84 bool WriteHeader(const PacketInfo& packet_info, | |
85 uint8_t* buffer, | |
86 size_t* header_length) const; | |
87 | |
88 const RTPVideoHeaderVP9 hdr_; | |
89 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. | |
91 size_t payload_size_; // The size in bytes of the payload data. | |
92 PacketInfoQueue packets_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); | |
95 }; | |
96 | |
97 | |
98 class RtpDepacketizerVp9 : public RtpDepacketizer { | |
99 public: | |
100 virtual ~RtpDepacketizerVp9() {} | |
101 | |
102 bool Parse(ParsedPayload* parsed_payload, | |
103 const uint8_t* payload, | |
104 size_t payload_length) override; | |
105 }; | |
106 | |
107 } // namespace webrtc | |
108 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ | |
OLD | NEW |