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

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

Issue 1351473006: WebmMuxer-MediaRecorderHandler: thread hopping and data ownership (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: StringPiece passed by value 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
« no previous file with comments | « no previous file | content/renderer/media/media_recorder_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace media { 22 namespace media {
23 class VideoFrame; 23 class VideoFrame;
24 class WebmMuxer; 24 class WebmMuxer;
25 } // namespace media 25 } // namespace media
26 26
27 namespace content { 27 namespace content {
28 28
29 class VideoTrackRecorder; 29 class VideoTrackRecorder;
30 30
31 // MediaRecorderHandler orchestrates the creation, lifetime mgmt and mapping 31 // MediaRecorderHandler orchestrates the creation, lifetime management and
32 // between: 32 // mapping between:
33 // - MediaStreamTrack(s) providing data, 33 // - MediaStreamTrack(s) providing data,
34 // - {Audio,Video}TrackRecorders encoding that data, 34 // - {Audio,Video}TrackRecorders encoding that data,
35 // - a WebmMuxer class multiplexing encoded data into a WebM container, and 35 // - a WebmMuxer class multiplexing encoded data into a WebM container, and
36 // - a single recorder client receiving this contained data. 36 // - a single recorder client receiving this contained data.
37 // 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,
38 // i.e. the Main Render thread. 38 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to
39 // TODO(mcasas): Implement audio recording. 39 // guarantee this, since VideoTrackRecorder sends back frames on IO thread.)
40 // TODO(mcasas): http://crbug.com/528519 Implement audio recording.
40 class CONTENT_EXPORT MediaRecorderHandler final 41 class CONTENT_EXPORT MediaRecorderHandler final
41 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler) { 42 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler) {
42 public: 43 public:
43 MediaRecorderHandler(); 44 MediaRecorderHandler();
44 ~MediaRecorderHandler() override; 45 ~MediaRecorderHandler() override;
45 46
46 // See above, these methods should override blink::WebMediaRecorderHandler. 47 // blink::WebMediaRecorderHandler.
47 bool canSupportMimeType(const blink::WebString& mimeType) override; 48 bool canSupportMimeType(const blink::WebString& mimeType) override;
48 bool initialize(blink::WebMediaRecorderHandlerClient* client, 49 bool initialize(blink::WebMediaRecorderHandlerClient* client,
49 const blink::WebMediaStream& media_stream, 50 const blink::WebMediaStream& media_stream,
50 const blink::WebString& mimeType) override; 51 const blink::WebString& mimeType) override;
51 bool start() override; 52 bool start() override;
52 bool start(int timeslice) override; 53 bool start(int timeslice) override;
53 void stop() override; 54 void stop() override;
54 void pause() override; 55 void pause() override;
55 void resume() override; 56 void resume() override;
56 57
57 private: 58 private:
58 friend class MediaRecorderHandlerTest; 59 friend class MediaRecorderHandlerTest;
59 60
60 void WriteData(const base::StringPiece& data); 61 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame,
62 scoped_ptr<std::string> encoded_data,
63 base::TimeTicks timestamp,
64 bool is_key_frame);
65 void WriteData(base::StringPiece data);
61 66
62 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, 67 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame,
63 const base::TimeTicks& timestamp); 68 const base::TimeTicks& timestamp);
64 69
65 // Bound to the main render thread. 70 // Bound to the main render thread.
66 base::ThreadChecker main_render_thread_checker_; 71 base::ThreadChecker main_render_thread_checker_;
67 72
68 bool recording_; 73 bool recording_;
69 blink::WebMediaStream media_stream_; // The MediaStream being recorded. 74 blink::WebMediaStream media_stream_; // The MediaStream being recorded.
70 75
71 // |client_| is a weak pointer, and is valid for the lifetime of this object. 76 // |client_| is a weak pointer, and is valid for the lifetime of this object.
72 blink::WebMediaRecorderHandlerClient* client_; 77 blink::WebMediaRecorderHandlerClient* client_;
73 78
74 ScopedVector<VideoTrackRecorder> video_recorders_; 79 ScopedVector<VideoTrackRecorder> video_recorders_;
75 80
76 // Worker class doing the actual Webm Muxing work. 81 // Worker class doing the actual Webm Muxing work.
77 scoped_ptr<media::WebmMuxer> webm_muxer_; 82 scoped_ptr<media::WebmMuxer> webm_muxer_;
78 83
79 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; 84 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_;
80 85
81 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); 86 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler);
82 }; 87 };
83 88
84 } // namespace content 89 } // namespace content
85 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ 90 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/media_recorder_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698