| OLD | NEW |
| 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 CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/renderer/media/video_track_recorder.h" |
| 17 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" | 18 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" |
| 18 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 19 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 class WebMediaRecorderHandlerClient; | 22 class WebMediaRecorderHandlerClient; |
| 22 class WebString; | 23 class WebString; |
| 23 } // namespace blink | 24 } // namespace blink |
| 24 | 25 |
| 25 namespace media { | 26 namespace media { |
| 26 class AudioBus; | 27 class AudioBus; |
| 27 class AudioParameters; | 28 class AudioParameters; |
| 28 class VideoFrame; | 29 class VideoFrame; |
| 29 class WebmMuxer; | 30 class WebmMuxer; |
| 30 } // namespace media | 31 } // namespace media |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 class VideoTrackRecorder; | |
| 35 class AudioTrackRecorder; | 35 class AudioTrackRecorder; |
| 36 | 36 |
| 37 // MediaRecorderHandler orchestrates the creation, lifetime management and | 37 // MediaRecorderHandler orchestrates the creation, lifetime management and |
| 38 // mapping between: | 38 // mapping between: |
| 39 // - MediaStreamTrack(s) providing data, | 39 // - MediaStreamTrack(s) providing data, |
| 40 // - {Audio,Video}TrackRecorders encoding that data, | 40 // - {Audio,Video}TrackRecorders encoding that data, |
| 41 // - a WebmMuxer class multiplexing encoded data into a WebM container, and | 41 // - a WebmMuxer class multiplexing encoded data into a WebM container, and |
| 42 // - a single recorder client receiving this contained data. | 42 // - a single recorder client receiving this contained data. |
| 43 // All methods are called on the same thread as construction and destruction, | 43 // All methods are called on the same thread as construction and destruction, |
| 44 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to | 44 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 const base::TimeTicks& timestamp); | 82 const base::TimeTicks& timestamp); |
| 83 void SetAudioFormatForTesting(const media::AudioParameters& params); | 83 void SetAudioFormatForTesting(const media::AudioParameters& params); |
| 84 | 84 |
| 85 // Bound to the main render thread. | 85 // Bound to the main render thread. |
| 86 base::ThreadChecker main_render_thread_checker_; | 86 base::ThreadChecker main_render_thread_checker_; |
| 87 | 87 |
| 88 // Sanitized video and audio bitrate settings passed on initialize(). | 88 // Sanitized video and audio bitrate settings passed on initialize(). |
| 89 int32_t video_bits_per_second_; | 89 int32_t video_bits_per_second_; |
| 90 int32_t audio_bits_per_second_; | 90 int32_t audio_bits_per_second_; |
| 91 | 91 |
| 92 // Force using VP9 for video encoding, otherwise VP8 will be used by default. | 92 // Video Codec, VP8 is used by default. |
| 93 bool use_vp9_; | 93 VideoTrackRecorder::CodecId codec_id_; |
| 94 | 94 |
| 95 // |client_| has no notion of time, thus may configure us via start(timeslice) | 95 // |client_| has no notion of time, thus may configure us via start(timeslice) |
| 96 // to notify it after a certain |timeslice_| has passed. We use a moving | 96 // to notify it after a certain |timeslice_| has passed. We use a moving |
| 97 // |slice_origin_timestamp_| to track those time chunks. | 97 // |slice_origin_timestamp_| to track those time chunks. |
| 98 base::TimeDelta timeslice_; | 98 base::TimeDelta timeslice_; |
| 99 base::TimeTicks slice_origin_timestamp_; | 99 base::TimeTicks slice_origin_timestamp_; |
| 100 | 100 |
| 101 bool recording_; | 101 bool recording_; |
| 102 blink::WebMediaStream media_stream_; // The MediaStream being recorded. | 102 blink::WebMediaStream media_stream_; // The MediaStream being recorded. |
| 103 | 103 |
| 104 // |client_| is a weak pointer, and is valid for the lifetime of this object. | 104 // |client_| is a weak pointer, and is valid for the lifetime of this object. |
| 105 blink::WebMediaRecorderHandlerClient* client_; | 105 blink::WebMediaRecorderHandlerClient* client_; |
| 106 | 106 |
| 107 ScopedVector<VideoTrackRecorder> video_recorders_; | 107 ScopedVector<VideoTrackRecorder> video_recorders_; |
| 108 ScopedVector<AudioTrackRecorder> audio_recorders_; | 108 ScopedVector<AudioTrackRecorder> audio_recorders_; |
| 109 | 109 |
| 110 // Worker class doing the actual Webm Muxing work. | 110 // Worker class doing the actual Webm Muxing work. |
| 111 std::unique_ptr<media::WebmMuxer> webm_muxer_; | 111 std::unique_ptr<media::WebmMuxer> webm_muxer_; |
| 112 | 112 |
| 113 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; | 113 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); | 115 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace content | 118 } // namespace content |
| 119 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 119 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ |
| OLD | NEW |