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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Get parameter set information. | 49 // Get parameter set information. |
50 int nalu_header_size = 0; | 50 int nalu_header_size = 0; |
51 size_t param_set_count = 0; | 51 size_t param_set_count = 0; |
52 OSStatus status = CMVideoFormatDescriptionGetH264ParameterSetAtIndex( | 52 OSStatus status = CMVideoFormatDescriptionGetH264ParameterSetAtIndex( |
53 description, 0, nullptr, nullptr, ¶m_set_count, &nalu_header_size); | 53 description, 0, nullptr, nullptr, ¶m_set_count, &nalu_header_size); |
54 if (status != noErr) { | 54 if (status != noErr) { |
55 LOG(LS_ERROR) << "Failed to get parameter set."; | 55 LOG(LS_ERROR) << "Failed to get parameter set."; |
56 return false; | 56 return false; |
57 } | 57 } |
58 RTC_CHECK_EQ(nalu_header_size, kAvccHeaderByteSize); | 58 RTC_CHECK_EQ(nalu_header_size, kAvccHeaderByteSize); |
59 RTC_DCHECK_EQ(param_set_count, 2u); | 59 RTC_DCHECK_EQ(param_set_count, 2); |
60 | 60 |
61 // Truncate any previous data in the buffer without changing its capacity. | 61 // Truncate any previous data in the buffer without changing its capacity. |
62 annexb_buffer->SetSize(0); | 62 annexb_buffer->SetSize(0); |
63 | 63 |
64 size_t nalu_offset = 0; | 64 size_t nalu_offset = 0; |
65 std::vector<size_t> frag_offsets; | 65 std::vector<size_t> frag_offsets; |
66 std::vector<size_t> frag_lengths; | 66 std::vector<size_t> frag_lengths; |
67 | 67 |
68 // Place all parameter sets at the front of buffer. | 68 // Place all parameter sets at the front of buffer. |
69 if (is_keyframe) { | 69 if (is_keyframe) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 CFRelease(contiguous_buffer); | 243 CFRelease(contiguous_buffer); |
244 return false; | 244 return false; |
245 } | 245 } |
246 CFRelease(contiguous_buffer); | 246 CFRelease(contiguous_buffer); |
247 return true; | 247 return true; |
248 } | 248 } |
249 | 249 |
250 bool H264AnnexBBufferHasVideoFormatDescription(const uint8_t* annexb_buffer, | 250 bool H264AnnexBBufferHasVideoFormatDescription(const uint8_t* annexb_buffer, |
251 size_t annexb_buffer_size) { | 251 size_t annexb_buffer_size) { |
252 RTC_DCHECK(annexb_buffer); | 252 RTC_DCHECK(annexb_buffer); |
253 RTC_DCHECK_GT(annexb_buffer_size, 4u); | 253 RTC_DCHECK_GT(annexb_buffer_size, 4); |
254 | 254 |
255 // The buffer we receive via RTP has 00 00 00 01 start code artifically | 255 // The buffer we receive via RTP has 00 00 00 01 start code artifically |
256 // embedded by the RTP depacketizer. Extract NALU information. | 256 // embedded by the RTP depacketizer. Extract NALU information. |
257 // TODO(tkchin): handle potential case where sps and pps are delivered | 257 // TODO(tkchin): handle potential case where sps and pps are delivered |
258 // separately. | 258 // separately. |
259 NaluType first_nalu_type = ParseNaluType(annexb_buffer[4]); | 259 NaluType first_nalu_type = ParseNaluType(annexb_buffer[4]); |
260 bool is_first_nalu_type_sps = first_nalu_type == kSps; | 260 bool is_first_nalu_type_sps = first_nalu_type == kSps; |
261 if (is_first_nalu_type_sps) | 261 if (is_first_nalu_type_sps) |
262 return true; | 262 return true; |
263 bool is_first_nalu_type_aud = first_nalu_type == kAud; | 263 bool is_first_nalu_type_aud = first_nalu_type == kAud; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 memcpy(start_ + offset_, data, data_size); | 356 memcpy(start_ + offset_, data, data_size); |
357 offset_ += data_size; | 357 offset_ += data_size; |
358 return true; | 358 return true; |
359 } | 359 } |
360 | 360 |
361 size_t AvccBufferWriter::BytesRemaining() const { | 361 size_t AvccBufferWriter::BytesRemaining() const { |
362 return length_ - offset_; | 362 return length_ - offset_; |
363 } | 363 } |
364 | 364 |
365 } // namespace webrtc | 365 } // namespace webrtc |
OLD | NEW |