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

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

Powered by Google App Engine
This is Rietveld 408576698