| 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/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/renderer/media/media_stream.h" |
| 14 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" | 15 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" |
| 15 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 16 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 class WebMediaRecorderHandlerClient; | 19 class WebMediaRecorderHandlerClient; |
| 19 class WebString; | 20 class WebString; |
| 20 } // namespace blink | 21 } // namespace blink |
| 21 | 22 |
| 22 namespace media { | 23 namespace media { |
| 23 class AudioBus; | 24 class AudioBus; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 // MediaRecorderHandler orchestrates the creation, lifetime management and | 35 // MediaRecorderHandler orchestrates the creation, lifetime management and |
| 35 // mapping between: | 36 // mapping between: |
| 36 // - MediaStreamTrack(s) providing data, | 37 // - MediaStreamTrack(s) providing data, |
| 37 // - {Audio,Video}TrackRecorders encoding that data, | 38 // - {Audio,Video}TrackRecorders encoding that data, |
| 38 // - a WebmMuxer class multiplexing encoded data into a WebM container, and | 39 // - a WebmMuxer class multiplexing encoded data into a WebM container, and |
| 39 // - a single recorder client receiving this contained data. | 40 // - a single recorder client receiving this contained data. |
| 40 // All methods are called on the same thread as construction and destruction, | 41 // All methods are called on the same thread as construction and destruction, |
| 41 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to | 42 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to |
| 42 // guarantee this, since VideoTrackRecorder sends back frames on IO thread.) | 43 // guarantee this, since VideoTrackRecorder sends back frames on IO thread.) |
| 43 class CONTENT_EXPORT MediaRecorderHandler final | 44 class CONTENT_EXPORT MediaRecorderHandler final |
| 44 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler) { | 45 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler), |
| 46 public NON_EXPORTED_BASE(MediaStreamObserver) { |
| 45 public: | 47 public: |
| 46 MediaRecorderHandler(); | 48 MediaRecorderHandler(); |
| 47 ~MediaRecorderHandler() override; | 49 ~MediaRecorderHandler() override; |
| 48 | 50 |
| 49 // blink::WebMediaRecorderHandler. | 51 // blink::WebMediaRecorderHandler. |
| 50 bool canSupportMimeType(const blink::WebString& web_type, | 52 bool canSupportMimeType(const blink::WebString& web_type, |
| 51 const blink::WebString& web_codecs) override; | 53 const blink::WebString& web_codecs) override; |
| 52 bool initialize(blink::WebMediaRecorderHandlerClient* client, | 54 bool initialize(blink::WebMediaRecorderHandlerClient* client, |
| 53 const blink::WebMediaStream& media_stream, | 55 const blink::WebMediaStream& media_stream, |
| 54 const blink::WebString& type, | 56 const blink::WebString& type, |
| 55 const blink::WebString& codecs) override; | 57 const blink::WebString& codecs) override; |
| 56 bool start() override; | 58 bool start() override; |
| 57 bool start(int timeslice) override; | 59 bool start(int timeslice) override; |
| 58 void stop() override; | 60 void stop() override; |
| 59 void pause() override; | 61 void pause() override; |
| 60 void resume() override; | 62 void resume() override; |
| 61 | 63 |
| 64 // MediaStreamObserver implementation. On MS modification, we stop recording |
| 65 // and signal this illegal condition to |client_|. |
| 66 void TrackAdded(const blink::WebMediaStreamTrack& track) override; |
| 67 void TrackRemoved(const blink::WebMediaStreamTrack& track) override; |
| 68 |
| 62 private: | 69 private: |
| 63 friend class MediaRecorderHandlerTest; | 70 friend class MediaRecorderHandlerTest; |
| 64 | 71 |
| 65 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame, | 72 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame, |
| 66 scoped_ptr<std::string> encoded_data, | 73 scoped_ptr<std::string> encoded_data, |
| 67 base::TimeTicks timestamp, | 74 base::TimeTicks timestamp, |
| 68 bool is_key_frame); | 75 bool is_key_frame); |
| 69 void OnEncodedAudio(const media::AudioParameters& params, | 76 void OnEncodedAudio(const media::AudioParameters& params, |
| 70 scoped_ptr<std::string> encoded_data, | 77 scoped_ptr<std::string> encoded_data, |
| 71 base::TimeTicks timestamp); | 78 base::TimeTicks timestamp); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 // Worker class doing the actual Webm Muxing work. | 108 // Worker class doing the actual Webm Muxing work. |
| 102 scoped_ptr<media::WebmMuxer> webm_muxer_; | 109 scoped_ptr<media::WebmMuxer> webm_muxer_; |
| 103 | 110 |
| 104 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; | 111 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; |
| 105 | 112 |
| 106 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); | 113 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); |
| 107 }; | 114 }; |
| 108 | 115 |
| 109 } // namespace content | 116 } // namespace content |
| 110 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 117 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ |
| OLD | NEW |