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

Side by Side Diff: media/muxers/webm_muxer.cc

Issue 1886123002: [experimental] MR: add support for H264 recording (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « media/muxers/webm_muxer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/muxers/webm_muxer.h" 5 #include "media/muxers/webm_muxer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/audio/audio_parameters.h" 8 #include "media/audio/audio_parameters.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 return frame_rate; 68 return frame_rate;
69 } 69 }
70 70
71 } // anonymous namespace 71 } // anonymous namespace
72 72
73 WebmMuxer::WebmMuxer(VideoCodec codec, 73 WebmMuxer::WebmMuxer(VideoCodec codec,
74 bool has_video, 74 bool has_video,
75 bool has_audio, 75 bool has_audio,
76 const WriteDataCB& write_data_callback) 76 const WriteDataCB& write_data_callback)
77 : use_vp9_(codec == kCodecVP9), 77 : codec_(codec),
78 video_track_index_(0), 78 video_track_index_(0),
79 audio_track_index_(0), 79 audio_track_index_(0),
80 has_video_(has_video), 80 has_video_(has_video),
81 has_audio_(has_audio), 81 has_audio_(has_audio),
82 write_data_callback_(write_data_callback), 82 write_data_callback_(write_data_callback),
83 position_(0) { 83 position_(0) {
84 DCHECK(has_video_ || has_audio_); 84 DCHECK(has_video_ || has_audio_);
85 DCHECK(!write_data_callback_.is_null()); 85 DCHECK(!write_data_callback_.is_null());
86 DCHECK(codec == kCodecVP8 || codec == kCodecVP9) 86 DCHECK(codec_ == kCodecVP8 || codec_ == kCodecVP9|| codec_ == kCodecH264)
87 << " Only Vp8 and VP9 are supported in WebmMuxer"; 87 << " Unsupported codec " << GetCodecName(codec_);
88 88
89 segment_.Init(this); 89 segment_.Init(this);
90 segment_.set_mode(mkvmuxer::Segment::kLive); 90 segment_.set_mode(mkvmuxer::Segment::kLive);
91 segment_.OutputCues(false); 91 segment_.OutputCues(false);
92 92
93 mkvmuxer::SegmentInfo* const info = segment_.GetSegmentInfo(); 93 mkvmuxer::SegmentInfo* const info = segment_.GetSegmentInfo();
94 info->set_writing_app("Chrome"); 94 info->set_writing_app("Chrome");
95 info->set_muxing_app("Chrome"); 95 info->set_muxing_app("Chrome");
96 96
97 // Creation is done on a different thread than main activities. 97 // Creation is done on a different thread than main activities.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 << "WebmMuxer can only be initialized once."; 200 << "WebmMuxer can only be initialized once.";
201 201
202 video_track_index_ = 202 video_track_index_ =
203 segment_.AddVideoTrack(frame_size.width(), frame_size.height(), 0); 203 segment_.AddVideoTrack(frame_size.width(), frame_size.height(), 0);
204 DCHECK_GT(video_track_index_, 0u); 204 DCHECK_GT(video_track_index_, 0u);
205 205
206 mkvmuxer::VideoTrack* const video_track = 206 mkvmuxer::VideoTrack* const video_track =
207 reinterpret_cast<mkvmuxer::VideoTrack*>( 207 reinterpret_cast<mkvmuxer::VideoTrack*>(
208 segment_.GetTrackByNumber(video_track_index_)); 208 segment_.GetTrackByNumber(video_track_index_));
209 DCHECK(video_track); 209 DCHECK(video_track);
210 video_track->set_codec_id(use_vp9_ ? mkvmuxer::Tracks::kVp9CodecId 210 if (codec_ == kCodecVP9)
211 : mkvmuxer::Tracks::kVp8CodecId); 211 video_track->set_codec_id(mkvmuxer::Tracks::kVp9CodecId);
212 else if (codec_ == kCodecVP8)
213 video_track->set_codec_id(mkvmuxer::Tracks::kVp8CodecId);
214 else
215 video_track->set_codec_id(mkvmuxer::Tracks::kVp8CodecId);
216
212 DCHECK_EQ(0ull, video_track->crop_right()); 217 DCHECK_EQ(0ull, video_track->crop_right());
213 DCHECK_EQ(0ull, video_track->crop_left()); 218 DCHECK_EQ(0ull, video_track->crop_left());
214 DCHECK_EQ(0ull, video_track->crop_top()); 219 DCHECK_EQ(0ull, video_track->crop_top());
215 DCHECK_EQ(0ull, video_track->crop_bottom()); 220 DCHECK_EQ(0ull, video_track->crop_bottom());
216 DCHECK_EQ(0.0f, video_track->frame_rate()); 221 DCHECK_EQ(0.0f, video_track->frame_rate());
217 222
218 video_track->set_default_duration(base::Time::kNanosecondsPerSecond / 223 video_track->set_default_duration(base::Time::kNanosecondsPerSecond /
219 frame_rate); 224 frame_rate);
220 // Segment's timestamps should be in milliseconds, DCHECK it. See 225 // Segment's timestamps should be in milliseconds, DCHECK it. See
221 // http://www.webmproject.org/docs/container/#muxer-guidelines 226 // http://www.webmproject.org/docs/container/#muxer-guidelines
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 305 }
301 306
302 WebmMuxer::EncodedVideoFrame::EncodedVideoFrame(scoped_ptr<std::string> data, 307 WebmMuxer::EncodedVideoFrame::EncodedVideoFrame(scoped_ptr<std::string> data,
303 base::TimeTicks timestamp, 308 base::TimeTicks timestamp,
304 bool is_keyframe) 309 bool is_keyframe)
305 : data(std::move(data)), timestamp(timestamp), is_keyframe(is_keyframe) {} 310 : data(std::move(data)), timestamp(timestamp), is_keyframe(is_keyframe) {}
306 311
307 WebmMuxer::EncodedVideoFrame::~EncodedVideoFrame() {} 312 WebmMuxer::EncodedVideoFrame::~EncodedVideoFrame() {}
308 313
309 } // namespace media 314 } // namespace media
OLDNEW
« no previous file with comments | « media/muxers/webm_muxer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698