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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 public: | 46 public: |
47 MediaRecorderHandler(); | 47 MediaRecorderHandler(); |
48 ~MediaRecorderHandler() override; | 48 ~MediaRecorderHandler() override; |
49 | 49 |
50 // blink::WebMediaRecorderHandler. | 50 // blink::WebMediaRecorderHandler. |
51 bool canSupportMimeType(const blink::WebString& web_type, | 51 bool canSupportMimeType(const blink::WebString& web_type, |
52 const blink::WebString& web_codecs) override; | 52 const blink::WebString& web_codecs) override; |
53 bool initialize(blink::WebMediaRecorderHandlerClient* client, | 53 bool initialize(blink::WebMediaRecorderHandlerClient* client, |
54 const blink::WebMediaStream& media_stream, | 54 const blink::WebMediaStream& media_stream, |
55 const blink::WebString& type, | 55 const blink::WebString& type, |
56 const blink::WebString& codecs) override; | 56 const blink::WebString& codecs, |
| 57 int32_t audio_bits_per_second, |
| 58 int32_t video_bits_per_second) override; |
57 bool start() override; | 59 bool start() override; |
58 bool start(int timeslice) override; | 60 bool start(int timeslice) override; |
59 void stop() override; | 61 void stop() override; |
60 void pause() override; | 62 void pause() override; |
61 void resume() override; | 63 void resume() override; |
62 | 64 |
63 private: | 65 private: |
64 friend class MediaRecorderHandlerTest; | 66 friend class MediaRecorderHandlerTest; |
65 | 67 |
66 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame, | 68 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame, |
67 scoped_ptr<std::string> encoded_data, | 69 scoped_ptr<std::string> encoded_data, |
68 base::TimeTicks timestamp, | 70 base::TimeTicks timestamp, |
69 bool is_key_frame); | 71 bool is_key_frame); |
70 void OnEncodedAudio(const media::AudioParameters& params, | 72 void OnEncodedAudio(const media::AudioParameters& params, |
71 scoped_ptr<std::string> encoded_data, | 73 scoped_ptr<std::string> encoded_data, |
72 base::TimeTicks timestamp); | 74 base::TimeTicks timestamp); |
73 void WriteData(base::StringPiece data); | 75 void WriteData(base::StringPiece data); |
74 | 76 |
75 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, | 77 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, |
76 const base::TimeTicks& timestamp); | 78 const base::TimeTicks& timestamp); |
77 void OnAudioBusForTesting(const media::AudioBus& audio_bus, | 79 void OnAudioBusForTesting(const media::AudioBus& audio_bus, |
78 const base::TimeTicks& timestamp); | 80 const base::TimeTicks& timestamp); |
79 void SetAudioFormatForTesting(const media::AudioParameters& params); | 81 void SetAudioFormatForTesting(const media::AudioParameters& params); |
80 | 82 |
81 // Bound to the main render thread. | 83 // Bound to the main render thread. |
82 base::ThreadChecker main_render_thread_checker_; | 84 base::ThreadChecker main_render_thread_checker_; |
83 | 85 |
| 86 // Sanitized video and audio bitrate settings passed on initialize(). |
| 87 int32_t video_bits_per_second_; |
| 88 int32_t audio_bits_per_second_; |
| 89 |
84 // Force using VP9 for video encoding, otherwise VP8 will be used by default. | 90 // Force using VP9 for video encoding, otherwise VP8 will be used by default. |
85 bool use_vp9_; | 91 bool use_vp9_; |
86 | 92 |
87 // |client_| has no notion of time, thus may configure us via start(timeslice) | 93 // |client_| has no notion of time, thus may configure us via start(timeslice) |
88 // to notify it after a certain |timeslice_| has passed. We use a moving | 94 // to notify it after a certain |timeslice_| has passed. We use a moving |
89 // |slice_origin_timestamp_| to track those time chunks. | 95 // |slice_origin_timestamp_| to track those time chunks. |
90 base::TimeDelta timeslice_; | 96 base::TimeDelta timeslice_; |
91 base::TimeTicks slice_origin_timestamp_; | 97 base::TimeTicks slice_origin_timestamp_; |
92 | 98 |
93 bool recording_; | 99 bool recording_; |
94 blink::WebMediaStream media_stream_; // The MediaStream being recorded. | 100 blink::WebMediaStream media_stream_; // The MediaStream being recorded. |
95 | 101 |
96 // |client_| is a weak pointer, and is valid for the lifetime of this object. | 102 // |client_| is a weak pointer, and is valid for the lifetime of this object. |
97 blink::WebMediaRecorderHandlerClient* client_; | 103 blink::WebMediaRecorderHandlerClient* client_; |
98 | 104 |
99 ScopedVector<VideoTrackRecorder> video_recorders_; | 105 ScopedVector<VideoTrackRecorder> video_recorders_; |
100 ScopedVector<AudioTrackRecorder> audio_recorders_; | 106 ScopedVector<AudioTrackRecorder> audio_recorders_; |
101 | 107 |
102 // Worker class doing the actual Webm Muxing work. | 108 // Worker class doing the actual Webm Muxing work. |
103 scoped_ptr<media::WebmMuxer> webm_muxer_; | 109 scoped_ptr<media::WebmMuxer> webm_muxer_; |
104 | 110 |
105 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; | 111 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; |
106 | 112 |
107 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); | 113 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); |
108 }; | 114 }; |
109 | 115 |
110 } // namespace content | 116 } // namespace content |
111 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 117 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ |
OLD | NEW |