| 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 */ |
| 11 | 11 |
| 12 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h" | 12 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h" |
| 13 | 13 |
| 14 #if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 14 #if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
| 15 | 15 |
| 16 #include <CoreFoundation/CoreFoundation.h> | 16 #include <CoreFoundation/CoreFoundation.h> |
| 17 #include <memory> |
| 17 #include <vector> | 18 #include <vector> |
| 18 | 19 |
| 19 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
| 21 | 22 |
| 22 namespace webrtc { | 23 namespace webrtc { |
| 23 | 24 |
| 24 const char kAnnexBHeaderBytes[4] = {0, 0, 0, 1}; | 25 const char kAnnexBHeaderBytes[4] = {0, 0, 0, 1}; |
| 25 const size_t kAvccHeaderByteSize = sizeof(uint32_t); | 26 const size_t kAvccHeaderByteSize = sizeof(uint32_t); |
| 26 | 27 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 frag_offsets.push_back(nalu_offset + sizeof(kAnnexBHeaderBytes)); | 133 frag_offsets.push_back(nalu_offset + sizeof(kAnnexBHeaderBytes)); |
| 133 frag_lengths.push_back(packet_size); | 134 frag_lengths.push_back(packet_size); |
| 134 nalu_offset += sizeof(kAnnexBHeaderBytes) + packet_size; | 135 nalu_offset += sizeof(kAnnexBHeaderBytes) + packet_size; |
| 135 | 136 |
| 136 size_t bytes_written = packet_size + nalu_header_size; | 137 size_t bytes_written = packet_size + nalu_header_size; |
| 137 bytes_remaining -= bytes_written; | 138 bytes_remaining -= bytes_written; |
| 138 data_ptr += bytes_written; | 139 data_ptr += bytes_written; |
| 139 } | 140 } |
| 140 RTC_DCHECK_EQ(bytes_remaining, (size_t)0); | 141 RTC_DCHECK_EQ(bytes_remaining, (size_t)0); |
| 141 | 142 |
| 142 rtc::scoped_ptr<webrtc::RTPFragmentationHeader> header; | 143 std::unique_ptr<webrtc::RTPFragmentationHeader> header; |
| 143 header.reset(new webrtc::RTPFragmentationHeader()); | 144 header.reset(new webrtc::RTPFragmentationHeader()); |
| 144 header->VerifyAndAllocateFragmentationHeader(frag_offsets.size()); | 145 header->VerifyAndAllocateFragmentationHeader(frag_offsets.size()); |
| 145 RTC_DCHECK_EQ(frag_lengths.size(), frag_offsets.size()); | 146 RTC_DCHECK_EQ(frag_lengths.size(), frag_offsets.size()); |
| 146 for (size_t i = 0; i < frag_offsets.size(); ++i) { | 147 for (size_t i = 0; i < frag_offsets.size(); ++i) { |
| 147 header->fragmentationOffset[i] = frag_offsets[i]; | 148 header->fragmentationOffset[i] = frag_offsets[i]; |
| 148 header->fragmentationLength[i] = frag_lengths[i]; | 149 header->fragmentationLength[i] = frag_lengths[i]; |
| 149 header->fragmentationPlType[i] = 0; | 150 header->fragmentationPlType[i] = 0; |
| 150 header->fragmentationTimeDiff[i] = 0; | 151 header->fragmentationTimeDiff[i] = 0; |
| 151 } | 152 } |
| 152 *out_header = header.release(); | 153 *out_header = header.release(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 return true; | 347 return true; |
| 347 } | 348 } |
| 348 | 349 |
| 349 size_t AvccBufferWriter::BytesRemaining() const { | 350 size_t AvccBufferWriter::BytesRemaining() const { |
| 350 return length_ - offset_; | 351 return length_ - offset_; |
| 351 } | 352 } |
| 352 | 353 |
| 353 } // namespace webrtc | 354 } // namespace webrtc |
| 354 | 355 |
| 355 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 356 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
| OLD | NEW |