| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 
|  | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 
|  | 7 | 
|  | 8 #include "base/memory/scoped_vector.h" | 
|  | 9 #include "base/memory/weak_ptr.h" | 
|  | 10 #include "base/strings/string_piece.h" | 
|  | 11 #include "base/threading/thread_checker.h" | 
|  | 12 #include "content/common/content_export.h" | 
|  | 13 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" | 
|  | 14 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 
|  | 15 #include "third_party/WebKit/public/platform/WebString.h" | 
|  | 16 | 
|  | 17 namespace media { | 
|  | 18 class VideoFrame; | 
|  | 19 class WebmMuxer; | 
|  | 20 }  // namespace media | 
|  | 21 | 
|  | 22 namespace content { | 
|  | 23 | 
|  | 24 class VideoTrackRecorder; | 
|  | 25 | 
|  | 26 // MediaRecorderHandler orchestrates the creation, lifetime mgmt and mapping | 
|  | 27 // between: | 
|  | 28 // - MediaStreamTrack(s) providing data, | 
|  | 29 // - {Audio,Video}TrackRecorders encoding that data, | 
|  | 30 // - a WebmMuxer class multiplexing encoded data into a WebM container, and | 
|  | 31 // - a single recorder client receiving this contained data. | 
|  | 32 // All methods are called on the same thread as construction and destruction, | 
|  | 33 // i.e. the Main Render thread. | 
|  | 34 // TODO(mcasas): Implement audio recording. | 
|  | 35 class CONTENT_EXPORT MediaRecorderHandler final | 
|  | 36     : NON_EXPORTED_BASE(public blink::WebMediaRecorderHandler) { | 
|  | 37  public: | 
|  | 38   MediaRecorderHandler(); | 
|  | 39   ~MediaRecorderHandler(); | 
|  | 40 | 
|  | 41   // Implements blink::WebMediaRecorderHandler. | 
|  | 42   bool canSupportMimeType(const blink::WebString& mimeType); | 
|  | 43   bool initialize(blink::WebMediaRecorderHandlerClient* client, | 
|  | 44                   const blink::WebMediaStream& media_stream, | 
|  | 45                   const blink::WebString& mimeType) override; | 
|  | 46   bool start() override; | 
|  | 47   bool start(int timeslice) override; | 
|  | 48   void stop() override; | 
|  | 49   void pause() override; | 
|  | 50   void resume() override; | 
|  | 51 | 
|  | 52  private: | 
|  | 53   friend class MediaRecorderHandlerTest; | 
|  | 54 | 
|  | 55   void WriteData(const base::StringPiece& data); | 
|  | 56 | 
|  | 57   void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, | 
|  | 58                               const base::TimeTicks& timestamp); | 
|  | 59 | 
|  | 60   // Bound to the main render thread. | 
|  | 61   base::ThreadChecker main_render_thread_checker_; | 
|  | 62 | 
|  | 63   bool recording_; | 
|  | 64   blink::WebMediaStream media_stream_;  // The MediaStream being recorded. | 
|  | 65 | 
|  | 66   // |client_| is a weak pointer, and is valid for the lifetime of this object. | 
|  | 67   blink::WebMediaRecorderHandlerClient* client_; | 
|  | 68 | 
|  | 69   ScopedVector<VideoTrackRecorder> video_recorders_; | 
|  | 70 | 
|  | 71   // Worker class doing the actual Webm Muxing work. | 
|  | 72   scoped_ptr<media::WebmMuxer> webm_muxer_; | 
|  | 73 | 
|  | 74   base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; | 
|  | 75 | 
|  | 76   DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); | 
|  | 77 }; | 
|  | 78 | 
|  | 79 }  // namespace content | 
|  | 80 #endif  // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ | 
| OLD | NEW | 
|---|