Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: webrtc/modules/video_coding/h264_sps_pps_tracker.cc

Issue 2565173009: Wire up H264 fmtp sprop-parameter-sets with H264SpsPpsTracker. (Closed)
Patch Set: Added comment. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 "webrtc/modules/video_coding/h264_sps_pps_tracker.h" 11 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h"
12 12
13 #include <string> 13 #include <string>
14 #include <utility>
14 15
15 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
17 #include "webrtc/common_video/h264/h264_common.h" 18 #include "webrtc/common_video/h264/h264_common.h"
19 #include "webrtc/common_video/h264/pps_parser.h"
20 #include "webrtc/common_video/h264/sps_parser.h"
18 #include "webrtc/modules/video_coding/frame_object.h" 21 #include "webrtc/modules/video_coding/frame_object.h"
19 #include "webrtc/modules/video_coding/packet_buffer.h" 22 #include "webrtc/modules/video_coding/packet_buffer.h"
20 23
21 namespace webrtc { 24 namespace webrtc {
22 namespace video_coding { 25 namespace video_coding {
23 26
24 namespace { 27 namespace {
25 const uint8_t start_code_h264[] = {0, 0, 0, 1}; 28 const uint8_t start_code_h264[] = {0, 0, 0, 1};
26 } // namespace 29 } // namespace
27 30
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 insert_at += sizeof(start_code_h264); 175 insert_at += sizeof(start_code_h264);
173 } 176 }
174 memcpy(insert_at, data, data_size); 177 memcpy(insert_at, data, data_size);
175 } 178 }
176 179
177 packet->dataPtr = buffer; 180 packet->dataPtr = buffer;
178 packet->sizeBytes = required_size; 181 packet->sizeBytes = required_size;
179 return kInsert; 182 return kInsert;
180 } 183 }
181 184
185 void H264SpsPpsTracker::InsertSpsPps(const std::vector<uint8_t>& sps,
186 const std::vector<uint8_t>& pps) {
187 rtc::Optional<SpsParser::SpsState> parsed_sps =
188 SpsParser::ParseSps(sps.data(), sps.size());
189 rtc::Optional<PpsParser::PpsState> parsed_pps =
190 PpsParser::ParsePps(pps.data(), pps.size());
191
192 if (!parsed_pps || !parsed_sps) {
193 LOG(LS_WARNING) << "Failed to parse SPS or PPS parameters.";
194 return;
195 }
196
197 SpsInfo sps_info;
198 sps_info.size = sps.size();
199 uint8_t* sps_data = new uint8_t[sps_info.size];
200 memcpy(sps_data, sps.data(), sps_info.size);
201 sps_info.data.reset(sps_data);
202 sps_data_[parsed_sps->id] = std::move(sps_info);
203
204 PpsInfo pps_info;
205 pps_info.size = pps.size();
206 pps_info.sps_id = parsed_pps->sps_id;
207 uint8_t* pps_data = new uint8_t[pps_info.size];
208 memcpy(pps_data, pps.data(), pps_info.size);
209 pps_info.data.reset(pps_data);
210 pps_data_[parsed_pps->id] = std::move(pps_info);
211 }
212
182 } // namespace video_coding 213 } // namespace video_coding
183 } // namespace webrtc 214 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698