| 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/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 11 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaRecorderHandlerClient.h" | 14 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" |
| 14 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 15 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 18 class WebMediaRecorderHandlerClient; |
| 17 class WebString; | 19 class WebString; |
| 18 } // namespace blink | 20 } // namespace blink |
| 19 | 21 |
| 20 namespace media { | 22 namespace media { |
| 21 class VideoFrame; | 23 class VideoFrame; |
| 22 class WebmMuxer; | 24 class WebmMuxer; |
| 23 } // namespace media | 25 } // namespace media |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 class VideoTrackRecorder; | 29 class VideoTrackRecorder; |
| 28 | 30 |
| 29 // MediaRecorderHandler orchestrates the creation, lifetime mgmt and mapping | 31 // MediaRecorderHandler orchestrates the creation, lifetime mgmt and mapping |
| 30 // between: | 32 // between: |
| 31 // - MediaStreamTrack(s) providing data, | 33 // - MediaStreamTrack(s) providing data, |
| 32 // - {Audio,Video}TrackRecorders encoding that data, | 34 // - {Audio,Video}TrackRecorders encoding that data, |
| 33 // - a WebmMuxer class multiplexing encoded data into a WebM container, and | 35 // - a WebmMuxer class multiplexing encoded data into a WebM container, and |
| 34 // - a single recorder client receiving this contained data. | 36 // - a single recorder client receiving this contained data. |
| 35 // All methods are called on the same thread as construction and destruction, | 37 // All methods are called on the same thread as construction and destruction, |
| 36 // i.e. the Main Render thread. | 38 // i.e. the Main Render thread. |
| 37 // TODO(mcasas): Implement audio recording. | 39 // TODO(mcasas): Implement audio recording. |
| 38 class CONTENT_EXPORT MediaRecorderHandler final { | 40 class CONTENT_EXPORT MediaRecorderHandler final |
| 41 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler) { |
| 39 public: | 42 public: |
| 40 MediaRecorderHandler(); | 43 MediaRecorderHandler(); |
| 41 ~MediaRecorderHandler(); | 44 ~MediaRecorderHandler() override; |
| 42 | 45 |
| 43 // See above, these methods should override blink::WebMediaRecorderHandler. | 46 // See above, these methods should override blink::WebMediaRecorderHandler. |
| 44 bool canSupportMimeType(const blink::WebString& mimeType); | 47 bool canSupportMimeType(const blink::WebString& mimeType) override; |
| 45 bool initialize(blink::WebMediaRecorderHandlerClient* client, | 48 bool initialize(blink::WebMediaRecorderHandlerClient* client, |
| 46 const blink::WebMediaStream& media_stream, | 49 const blink::WebMediaStream& media_stream, |
| 47 const blink::WebString& mimeType); | 50 const blink::WebString& mimeType) override; |
| 48 bool start(); | 51 bool start() override; |
| 49 bool start(int timeslice); | 52 bool start(int timeslice) override; |
| 50 void stop(); | 53 void stop() override; |
| 51 void pause(); | 54 void pause() override; |
| 52 void resume(); | 55 void resume() override; |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 friend class MediaRecorderHandlerTest; | 58 friend class MediaRecorderHandlerTest; |
| 56 | 59 |
| 57 void WriteData(const base::StringPiece& data); | 60 void WriteData(const base::StringPiece& data); |
| 58 | 61 |
| 59 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, | 62 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, |
| 60 const base::TimeTicks& timestamp); | 63 const base::TimeTicks& timestamp); |
| 61 | 64 |
| 62 // Bound to the main render thread. | 65 // Bound to the main render thread. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 // Worker class doing the actual Webm Muxing work. | 76 // Worker class doing the actual Webm Muxing work. |
| 74 scoped_ptr<media::WebmMuxer> webm_muxer_; | 77 scoped_ptr<media::WebmMuxer> webm_muxer_; |
| 75 | 78 |
| 76 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; | 79 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; |
| 77 | 80 |
| 78 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); | 81 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 } // namespace content | 84 } // namespace content |
| 82 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 85 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ |
| OLD | NEW |