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

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

Issue 1830383003: WebmMuxer: add Pause()/Resume() methods and internal time-in-pause (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « content/renderer/media/media_recorder_handler.cc ('k') | media/muxers/webm_muxer.cc » ('j') | 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 #ifndef MEDIA_MUXERS_WEBM_MUXER_H_ 5 #ifndef MEDIA_MUXERS_WEBM_MUXER_H_
6 #define MEDIA_MUXERS_WEBM_MUXER_H_ 6 #define MEDIA_MUXERS_WEBM_MUXER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/numerics/safe_math.h" 14 #include "base/numerics/safe_math.h"
15 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/timer/elapsed_timer.h"
18 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
19 #include "media/base/video_codecs.h" 20 #include "media/base/video_codecs.h"
20 #include "third_party/libwebm/source/mkvmuxer.hpp" 21 #include "third_party/libwebm/source/mkvmuxer.hpp"
21 22
22 namespace gfx { 23 namespace gfx {
23 class Size; 24 class Size;
24 } // namespace gfx 25 } // namespace gfx
25 26
26 namespace media { 27 namespace media {
27 28
(...skipping 28 matching lines...) Expand all
56 // Functions to add video and audio frames with |encoded_data.data()| 57 // Functions to add video and audio frames with |encoded_data.data()|
57 // to WebM Segment. 58 // to WebM Segment.
58 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame, 59 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame,
59 scoped_ptr<std::string> encoded_data, 60 scoped_ptr<std::string> encoded_data,
60 base::TimeTicks timestamp, 61 base::TimeTicks timestamp,
61 bool is_key_frame); 62 bool is_key_frame);
62 void OnEncodedAudio(const media::AudioParameters& params, 63 void OnEncodedAudio(const media::AudioParameters& params,
63 scoped_ptr<std::string> encoded_data, 64 scoped_ptr<std::string> encoded_data,
64 base::TimeTicks timestamp); 65 base::TimeTicks timestamp);
65 66
67 void Pause();
68 void Resume();
69
66 private: 70 private:
67 friend class WebmMuxerTest; 71 friend class WebmMuxerTest;
68 72
69 // Methods for creating and adding video and audio tracks, called upon 73 // Methods for creating and adding video and audio tracks, called upon
70 // receiving the first frame of a given Track. 74 // receiving the first frame of a given Track.
71 // AddVideoTrack adds |frame_size| and |frame_rate| to the Segment 75 // AddVideoTrack adds |frame_size| and |frame_rate| to the Segment
72 // info, although individual frames passed to OnEncodedVideo() can have any 76 // info, although individual frames passed to OnEncodedVideo() can have any
73 // frame size. 77 // frame size.
74 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate); 78 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate);
75 void AddAudioTrack(const media::AudioParameters& params); 79 void AddAudioTrack(const media::AudioParameters& params);
(...skipping 20 matching lines...) Expand all
96 100
97 // Caller-side identifiers to interact with |segment_|, initialised upon 101 // Caller-side identifiers to interact with |segment_|, initialised upon
98 // first frame arrival to Add{Video, Audio}Track(). 102 // first frame arrival to Add{Video, Audio}Track().
99 uint8_t video_track_index_; 103 uint8_t video_track_index_;
100 uint8_t audio_track_index_; 104 uint8_t audio_track_index_;
101 105
102 // Origin of times for frame timestamps. 106 // Origin of times for frame timestamps.
103 base::TimeTicks first_frame_timestamp_; 107 base::TimeTicks first_frame_timestamp_;
104 base::TimeDelta most_recent_timestamp_; 108 base::TimeDelta most_recent_timestamp_;
105 109
110 // Variables to measure and accumulate, respectively, the time in pause state.
111 scoped_ptr<base::ElapsedTimer> elapsed_time_in_pause_;
112 base::TimeDelta total_time_in_pause_;
113
106 // TODO(ajose): Change these when support is added for multiple tracks. 114 // TODO(ajose): Change these when support is added for multiple tracks.
107 // http://crbug.com/528523 115 // http://crbug.com/528523
108 const bool has_video_; 116 const bool has_video_;
109 const bool has_audio_; 117 const bool has_audio_;
110 118
111 // Callback to dump written data as being called by libwebm. 119 // Callback to dump written data as being called by libwebm.
112 const WriteDataCB write_data_callback_; 120 const WriteDataCB write_data_callback_;
113 121
114 // Rolling counter of the position in bytes of the written goo. 122 // Rolling counter of the position in bytes of the written goo.
115 base::CheckedNumeric<mkvmuxer::int64> position_; 123 base::CheckedNumeric<mkvmuxer::int64> position_;
(...skipping 17 matching lines...) Expand all
133 DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedVideoFrame); 141 DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedVideoFrame);
134 }; 142 };
135 std::deque<scoped_ptr<EncodedVideoFrame>> encoded_frames_queue_; 143 std::deque<scoped_ptr<EncodedVideoFrame>> encoded_frames_queue_;
136 144
137 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); 145 DISALLOW_COPY_AND_ASSIGN(WebmMuxer);
138 }; 146 };
139 147
140 } // namespace media 148 } // namespace media
141 149
142 #endif // MEDIA_MUXERS_WEBM_MUXER_H_ 150 #endif // MEDIA_MUXERS_WEBM_MUXER_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_recorder_handler.cc ('k') | media/muxers/webm_muxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698