| 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 15 matching lines...) Expand all Loading... |
| 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_extension_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 frame. |
| 47 void SetPayloadData(const uint8_t* payload, | 49 void 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 |
| 58 // Returns total number of packets will be produced. |
| 59 size_t TotalPackets() override; |
| 57 | 60 |
| 58 typedef struct { | 61 typedef struct { |
| 59 size_t payload_start_pos; | 62 size_t payload_start_pos; |
| 60 size_t size; | 63 size_t size; |
| 61 bool layer_begin; | 64 bool layer_begin; |
| 62 bool layer_end; | 65 bool layer_end; |
| 63 } PacketInfo; | 66 } PacketInfo; |
| 64 typedef std::queue<PacketInfo> PacketInfoQueue; | 67 typedef std::queue<PacketInfo> PacketInfoQueue; |
| 65 | 68 |
| 66 private: | 69 private: |
| 67 // Calculates all packet sizes and loads info to packet queue. | 70 // Calculates all packet sizes and loads info to packet queue. |
| 68 void GeneratePackets(); | 71 void GeneratePackets(); |
| 69 | 72 |
| 70 // Writes the payload descriptor header and copies payload to the |buffer|. | 73 // Writes the payload descriptor header and copies payload to the |buffer|. |
| 71 // |packet_info| determines which part of the payload to write. | 74 // |packet_info| determines which part of the payload to write. |
| 72 // |bytes_to_send| contains the number of written bytes to the buffer. | 75 // |last| indicates if the packet is last. |
| 73 // Returns true on success, false otherwise. | 76 // Returns true on success, false otherwise. |
| 74 bool WriteHeaderAndPayload(const PacketInfo& packet_info, | 77 bool WriteHeaderAndPayload(const PacketInfo& packet_info, |
| 75 RtpPacketToSend* packet) const; | 78 RtpPacketToSend* packet, |
| 79 bool last) const; |
| 76 | 80 |
| 77 // Writes payload descriptor header to |buffer|. | 81 // Writes payload descriptor header to |buffer|. |
| 78 // Returns true on success, false otherwise. | 82 // Returns true on success, false otherwise. |
| 79 bool WriteHeader(const PacketInfo& packet_info, | 83 bool WriteHeader(const PacketInfo& packet_info, |
| 80 uint8_t* buffer, | 84 uint8_t* buffer, |
| 81 size_t* header_length) const; | 85 size_t* header_length) const; |
| 82 | 86 |
| 83 const RTPVideoHeaderVP9 hdr_; | 87 const RTPVideoHeaderVP9 hdr_; |
| 84 const size_t max_payload_length_; // The max length in bytes of one packet. | 88 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. | 89 const uint8_t* payload_; // The payload data to be packetized. |
| 86 size_t payload_size_; // The size in bytes of the payload data. | 90 size_t payload_size_; // The size in bytes of the payload data. |
| 91 const size_t last_packet_extension_len_; |
| 87 PacketInfoQueue packets_; | 92 PacketInfoQueue packets_; |
| 88 | 93 |
| 89 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); | 94 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9); |
| 90 }; | 95 }; |
| 91 | 96 |
| 92 | 97 |
| 93 class RtpDepacketizerVp9 : public RtpDepacketizer { | 98 class RtpDepacketizerVp9 : public RtpDepacketizer { |
| 94 public: | 99 public: |
| 95 virtual ~RtpDepacketizerVp9() {} | 100 virtual ~RtpDepacketizerVp9() {} |
| 96 | 101 |
| 97 bool Parse(ParsedPayload* parsed_payload, | 102 bool Parse(ParsedPayload* parsed_payload, |
| 98 const uint8_t* payload, | 103 const uint8_t* payload, |
| 99 size_t payload_length) override; | 104 size_t payload_length) override; |
| 100 }; | 105 }; |
| 101 | 106 |
| 102 } // namespace webrtc | 107 } // namespace webrtc |
| 103 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ | 108 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_ |
| OLD | NEW |