Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: content/renderer/media/media_recorder_handler.h

Issue 1313603004: MediaRecorderHandler (video part) and unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, gyp and MediaRecorderHandlerTest Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/WebMediaStream.h"
14 #include "third_party/WebKit/public/platform/WebString.h"
15
16 namespace media {
17 class VideoFrame;
18 class WebmMuxer;
19 } // namespace media
20
21 namespace content {
22
23 class VideoTrackRecorder;
24
25 // TODO(mcasas): This class should derive from WebMediaRecorderHandler as
26 // defined in [1] whenever Blink http://crrev.com/1255873002 is landed, and use
27 // a WebMediaRecorderHandlerClient instead of MediaRecorderHandlerClient.
28 // [1] http://w3c.github.io/mediacapture-record/MediaRecorder.html#MediaRecorder API
29 class MediaRecorderHandlerClient {
30 public:
31 virtual ~MediaRecorderHandlerClient() = default;
32
33 virtual void writeData(const char* data, size_t length, bool lastInslice) = 0;
miu 2015/09/02 21:28:13 Should the name of the 3rd arg be lastInSlice (cap
mcasas 2015/09/04 02:16:30 Done.
34 };
35
36 // MediaRecorderHandler orchestrates the creation, lifetime mgmt and mapping
37 // between:
38 // - MediaStreamTrack(s) providing data,
39 // - {Audio,Video}TrackRecorders encoding that data,
40 // - a WebmMuxer class multiplexing encoded data into a WebM container, and
41 // - a single recorder |client_| receiving this contained data.
42 // All methods are called on the same thread as construction and destruction,
43 // i.e. the Main Render thread.
44 // TODO(mcasas): Implement audio recording.
45 class CONTENT_EXPORT MediaRecorderHandler final {
46 public:
47 MediaRecorderHandler();
48 ~MediaRecorderHandler();
49
50 // See above, these methods should override blink::WebMediaRecorderHandler.
51 bool canSupportMimeType(const blink::WebString& mimeType);
52 bool initialize(MediaRecorderHandlerClient* client,
53 const blink::WebMediaStream& media_stream,
54 const blink::WebString& mimeType);
55 bool start();
56 bool start(int timeslice);
57 void stop();
58 void pause();
59 void resume();
60
61 private:
62 friend class MediaRecorderHandlerTest;
63
64 void WriteData(const base::StringPiece& data);
65
66 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame,
67 const base::TimeTicks& timestamp);
68
69 // Bound to the main render thread.
70 base::ThreadChecker main_render_thread_checker_;
71
72 bool recording_;
miu 2015/09/02 21:28:13 You don't need this boolean. You could replace it
mcasas 2015/09/04 02:16:30 Still needs to be |recording_| == false between p
miu 2015/09/04 21:48:52 Acknowledged.
73 blink::WebMediaStream media_stream_; // The MediaStream being recorded.
74
75 // |client_| is a weak pointer, and is valid for the lifetime of this object.
76 MediaRecorderHandlerClient* client_;
77
78 ScopedVector<VideoTrackRecorder> video_recorders_;
79
80 // Worker class doing the actual Webm Muxing work.
81 scoped_ptr<media::WebmMuxer> webm_muxer_;
82
83 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_;
84
85 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler);
86 };
87
88 } // namespace content
89 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698