| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/modules/include/module_common_types.h" | 14 #include "webrtc/modules/include/module_common_types.h" |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" | 15 #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" |
| 17 | 17 |
| 18 namespace webrtc { | 18 namespace webrtc { |
| 19 | 19 |
| 20 static const size_t kGenericHeaderLength = 1; | 20 static const size_t kGenericHeaderLength = 1; |
| 21 | 21 |
| 22 RtpPacketizerGeneric::RtpPacketizerGeneric(FrameType frame_type, | 22 RtpPacketizerGeneric::RtpPacketizerGeneric(FrameType frame_type, |
| 23 size_t max_payload_len) | 23 size_t max_payload_len) |
| 24 : payload_data_(NULL), | 24 : payload_data_(nullptr), |
| 25 payload_size_(0), | 25 payload_size_(0), |
| 26 max_payload_len_(max_payload_len - kGenericHeaderLength), | 26 max_payload_len_(max_payload_len - kGenericHeaderLength), |
| 27 frame_type_(frame_type) { | 27 frame_type_(frame_type) {} |
| 28 } | |
| 29 | 28 |
| 30 RtpPacketizerGeneric::~RtpPacketizerGeneric() { | 29 RtpPacketizerGeneric::~RtpPacketizerGeneric() { |
| 31 } | 30 } |
| 32 | 31 |
| 33 void RtpPacketizerGeneric::SetPayloadData( | 32 void RtpPacketizerGeneric::SetPayloadData( |
| 34 const uint8_t* payload_data, | 33 const uint8_t* payload_data, |
| 35 size_t payload_size, | 34 size_t payload_size, |
| 36 const RTPFragmentationHeader* fragmentation) { | 35 const RTPFragmentationHeader* fragmentation) { |
| 37 payload_data_ = payload_data; | 36 payload_data_ = payload_data; |
| 38 payload_size_ = payload_size; | 37 payload_size_ = payload_size; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return kAllowRetransmission; | 84 return kAllowRetransmission; |
| 86 } | 85 } |
| 87 | 86 |
| 88 std::string RtpPacketizerGeneric::ToString() { | 87 std::string RtpPacketizerGeneric::ToString() { |
| 89 return "RtpPacketizerGeneric"; | 88 return "RtpPacketizerGeneric"; |
| 90 } | 89 } |
| 91 | 90 |
| 92 bool RtpDepacketizerGeneric::Parse(ParsedPayload* parsed_payload, | 91 bool RtpDepacketizerGeneric::Parse(ParsedPayload* parsed_payload, |
| 93 const uint8_t* payload_data, | 92 const uint8_t* payload_data, |
| 94 size_t payload_data_length) { | 93 size_t payload_data_length) { |
| 95 assert(parsed_payload != NULL); | 94 assert(parsed_payload != nullptr); |
| 96 if (payload_data_length == 0) { | 95 if (payload_data_length == 0) { |
| 97 LOG(LS_ERROR) << "Empty payload."; | 96 LOG(LS_ERROR) << "Empty payload."; |
| 98 return false; | 97 return false; |
| 99 } | 98 } |
| 100 | 99 |
| 101 uint8_t generic_header = *payload_data++; | 100 uint8_t generic_header = *payload_data++; |
| 102 --payload_data_length; | 101 --payload_data_length; |
| 103 | 102 |
| 104 parsed_payload->frame_type = | 103 parsed_payload->frame_type = |
| 105 ((generic_header & RtpFormatVideoGeneric::kKeyFrameBit) != 0) | 104 ((generic_header & RtpFormatVideoGeneric::kKeyFrameBit) != 0) |
| 106 ? kVideoFrameKey | 105 ? kVideoFrameKey |
| 107 : kVideoFrameDelta; | 106 : kVideoFrameDelta; |
| 108 parsed_payload->type.Video.is_first_packet_in_frame = | 107 parsed_payload->type.Video.is_first_packet_in_frame = |
| 109 (generic_header & RtpFormatVideoGeneric::kFirstPacketBit) != 0; | 108 (generic_header & RtpFormatVideoGeneric::kFirstPacketBit) != 0; |
| 110 parsed_payload->type.Video.codec = kRtpVideoGeneric; | 109 parsed_payload->type.Video.codec = kRtpVideoGeneric; |
| 111 parsed_payload->type.Video.width = 0; | 110 parsed_payload->type.Video.width = 0; |
| 112 parsed_payload->type.Video.height = 0; | 111 parsed_payload->type.Video.height = 0; |
| 113 | 112 |
| 114 parsed_payload->payload = payload_data; | 113 parsed_payload->payload = payload_data; |
| 115 parsed_payload->payload_length = payload_data_length; | 114 parsed_payload->payload_length = payload_data_length; |
| 116 return true; | 115 return true; |
| 117 } | 116 } |
| 118 } // namespace webrtc | 117 } // namespace webrtc |
| OLD | NEW |