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

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

Issue 1543673002: MediaRecorder: make MediaRecorderHandler a MediaStreamObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added content_browsertests for Error Event firing when Track added/removed to MS Created 4 years, 11 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
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/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/renderer/media/media_stream.h"
15 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h" 16 #include "third_party/WebKit/public/platform/WebMediaRecorderHandler.h"
16 #include "third_party/WebKit/public/platform/WebMediaStream.h" 17 #include "third_party/WebKit/public/platform/WebMediaStream.h"
17 18
18 namespace blink { 19 namespace blink {
19 class WebMediaRecorderHandlerClient; 20 class WebMediaRecorderHandlerClient;
20 class WebString; 21 class WebString;
21 } // namespace blink 22 } // namespace blink
22 23
23 namespace media { 24 namespace media {
24 class AudioBus; 25 class AudioBus;
(...skipping 10 matching lines...) Expand all
35 // MediaRecorderHandler orchestrates the creation, lifetime management and 36 // MediaRecorderHandler orchestrates the creation, lifetime management and
36 // mapping between: 37 // mapping between:
37 // - MediaStreamTrack(s) providing data, 38 // - MediaStreamTrack(s) providing data,
38 // - {Audio,Video}TrackRecorders encoding that data, 39 // - {Audio,Video}TrackRecorders encoding that data,
39 // - a WebmMuxer class multiplexing encoded data into a WebM container, and 40 // - a WebmMuxer class multiplexing encoded data into a WebM container, and
40 // - a single recorder client receiving this contained data. 41 // - a single recorder client receiving this contained data.
41 // All methods are called on the same thread as construction and destruction, 42 // All methods are called on the same thread as construction and destruction,
42 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to 43 // i.e. the Main Render thread. (Note that a BindToCurrentLoop is used to
43 // guarantee this, since VideoTrackRecorder sends back frames on IO thread.) 44 // guarantee this, since VideoTrackRecorder sends back frames on IO thread.)
44 class CONTENT_EXPORT MediaRecorderHandler final 45 class CONTENT_EXPORT MediaRecorderHandler final
45 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler) { 46 : public NON_EXPORTED_BASE(blink::WebMediaRecorderHandler),
47 public NON_EXPORTED_BASE(MediaStreamObserver) {
46 public: 48 public:
47 MediaRecorderHandler(); 49 MediaRecorderHandler();
48 ~MediaRecorderHandler() override; 50 ~MediaRecorderHandler() override;
49 51
50 // blink::WebMediaRecorderHandler. 52 // blink::WebMediaRecorderHandler.
51 bool canSupportMimeType(const blink::WebString& web_type, 53 bool canSupportMimeType(const blink::WebString& web_type,
52 const blink::WebString& web_codecs) override; 54 const blink::WebString& web_codecs) override;
53 bool initialize(blink::WebMediaRecorderHandlerClient* client, 55 bool initialize(blink::WebMediaRecorderHandlerClient* client,
54 const blink::WebMediaStream& media_stream, 56 const blink::WebMediaStream& web_media_stream,
55 const blink::WebString& type, 57 const blink::WebString& type,
56 const blink::WebString& codecs) override; 58 const blink::WebString& codecs) override;
57 bool start() override; 59 bool start() override;
58 bool start(int timeslice) override; 60 bool start(int timeslice) override;
59 void stop() override; 61 void stop() override;
60 void pause() override; 62 void pause() override;
61 void resume() override; 63 void resume() override;
62 64
65 // MediaStreamObserver implementation. On MS modification, we stop recording
66 // and signal this illegal condition to |client_|.
67 void TrackAdded(const blink::WebMediaStreamTrack& track) override;
68 void TrackRemoved(const blink::WebMediaStreamTrack& track) override;
69
63 private: 70 private:
64 friend class MediaRecorderHandlerTest; 71 friend class MediaRecorderHandlerTest;
65 72
66 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame, 73 void OnEncodedVideo(const scoped_refptr<media::VideoFrame>& video_frame,
67 scoped_ptr<std::string> encoded_data, 74 scoped_ptr<std::string> encoded_data,
68 base::TimeTicks timestamp, 75 base::TimeTicks timestamp,
69 bool is_key_frame); 76 bool is_key_frame);
70 void OnEncodedAudio(const media::AudioParameters& params, 77 void OnEncodedAudio(const media::AudioParameters& params,
71 scoped_ptr<std::string> encoded_data, 78 scoped_ptr<std::string> encoded_data,
72 base::TimeTicks timestamp); 79 base::TimeTicks timestamp);
(...skipping 11 matching lines...) Expand all
84 // Force using VP9 for video encoding, otherwise VP8 will be used by default. 91 // Force using VP9 for video encoding, otherwise VP8 will be used by default.
85 bool use_vp9_; 92 bool use_vp9_;
86 93
87 // |client_| has no notion of time, thus may configure us via start(timeslice) 94 // |client_| has no notion of time, thus may configure us via start(timeslice)
88 // to notify it after a certain |timeslice_| has passed. We use a moving 95 // to notify it after a certain |timeslice_| has passed. We use a moving
89 // |slice_origin_timestamp_| to track those time chunks. 96 // |slice_origin_timestamp_| to track those time chunks.
90 base::TimeDelta timeslice_; 97 base::TimeDelta timeslice_;
91 base::TimeTicks slice_origin_timestamp_; 98 base::TimeTicks slice_origin_timestamp_;
92 99
93 bool recording_; 100 bool recording_;
94 blink::WebMediaStream media_stream_; // The MediaStream being recorded. 101 blink::WebMediaStream web_media_stream_; // WebMediaStream being recorded.
95 102
96 // |client_| is a weak pointer, and is valid for the lifetime of this object. 103 // |client_| is a weak pointer, and is valid for the lifetime of this object.
97 blink::WebMediaRecorderHandlerClient* client_; 104 blink::WebMediaRecorderHandlerClient* client_;
98 105
99 ScopedVector<VideoTrackRecorder> video_recorders_; 106 ScopedVector<VideoTrackRecorder> video_recorders_;
100 ScopedVector<AudioTrackRecorder> audio_recorders_; 107 ScopedVector<AudioTrackRecorder> audio_recorders_;
101 108
102 // Worker class doing the actual Webm Muxing work. 109 // Worker class doing the actual Webm Muxing work.
103 scoped_ptr<media::WebmMuxer> webm_muxer_; 110 scoped_ptr<media::WebmMuxer> webm_muxer_;
104 111
105 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_; 112 base::WeakPtrFactory<MediaRecorderHandler> weak_factory_;
106 113
107 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler); 114 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandler);
108 }; 115 };
109 116
110 } // namespace content 117 } // namespace content
111 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_ 118 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RECORDER_HANDLER_H_
OLDNEW
« no previous file with comments | « content/public/renderer/media_stream_api.cc ('k') | content/renderer/media/media_recorder_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698