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

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

Issue 1142063003: content/child: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix. Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_VIDEO_TRACK_ADAPTER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ 6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 // Video frames are delivered to a track using a VideoCaptureDeliverFrameCB on 23 // Video frames are delivered to a track using a VideoCaptureDeliverFrameCB on
24 // the IO-thread. 24 // the IO-thread.
25 // Adaptations is done by wrapping the original media::VideoFrame in a new 25 // Adaptations is done by wrapping the original media::VideoFrame in a new
26 // media::VideoFrame with a new visible_rect and natural_size. 26 // media::VideoFrame with a new visible_rect and natural_size.
27 class VideoTrackAdapter 27 class VideoTrackAdapter
28 : public base::RefCountedThreadSafe<VideoTrackAdapter> { 28 : public base::RefCountedThreadSafe<VideoTrackAdapter> {
29 public: 29 public:
30 typedef base::Callback<void(bool mute_state)> OnMutedCallback; 30 typedef base::Callback<void(bool mute_state)> OnMutedCallback;
31 31
32 explicit VideoTrackAdapter( 32 explicit VideoTrackAdapter(
33 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); 33 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
34 34
35 // Register |track| to receive video frames in |frame_callback| with 35 // Register |track| to receive video frames in |frame_callback| with
36 // a resolution within the boundaries of the arguments. 36 // a resolution within the boundaries of the arguments.
37 // Must be called on the main render thread. |frame_callback| is guaranteed to 37 // Must be called on the main render thread. |frame_callback| is guaranteed to
38 // be released on the main render thread. 38 // be released on the main render thread.
39 // |source_frame_rate| is used to calculate a prudent interval to check for 39 // |source_frame_rate| is used to calculate a prudent interval to check for
40 // passing frames and inform of the result via |on_muted_state_callback|. 40 // passing frames and inform of the result via |on_muted_state_callback|.
41 void AddTrack(const MediaStreamVideoTrack* track, 41 void AddTrack(const MediaStreamVideoTrack* track,
42 VideoCaptureDeliverFrameCB frame_callback, 42 VideoCaptureDeliverFrameCB frame_callback,
43 int max_width, int max_height, 43 int max_width, int max_height,
44 double min_aspect_ratio, 44 double min_aspect_ratio,
45 double max_aspect_ratio, 45 double max_aspect_ratio,
46 double max_frame_rate); 46 double max_frame_rate);
47 void RemoveTrack(const MediaStreamVideoTrack* track); 47 void RemoveTrack(const MediaStreamVideoTrack* track);
48 48
49 // Delivers |frame| to all tracks that have registered a callback. 49 // Delivers |frame| to all tracks that have registered a callback.
50 // Must be called on the IO-thread. 50 // Must be called on the IO-thread.
51 void DeliverFrameOnIO( 51 void DeliverFrameOnIO(
52 const scoped_refptr<media::VideoFrame>& frame, 52 const scoped_refptr<media::VideoFrame>& frame,
53 const base::TimeTicks& estimated_capture_time); 53 const base::TimeTicks& estimated_capture_time);
54 54
55 const scoped_refptr<base::MessageLoopProxy>& io_message_loop() { 55 base::SingleThreadTaskRunner* io_task_runner() const {
56 DCHECK(thread_checker_.CalledOnValidThread()); 56 DCHECK(thread_checker_.CalledOnValidThread());
57 return io_message_loop_; 57 return io_task_runner_.get();
58 } 58 }
59 59
60 // Start monitor that frames are delivered to this object. I.E, that 60 // Start monitor that frames are delivered to this object. I.E, that
61 // |DeliverFrameOnIO| is called with a frame rate of |source_frame_rate|. 61 // |DeliverFrameOnIO| is called with a frame rate of |source_frame_rate|.
62 // |on_muted_callback| is triggered on the main render thread. 62 // |on_muted_callback| is triggered on the main render thread.
63 void StartFrameMonitoring(double source_frame_rate, 63 void StartFrameMonitoring(double source_frame_rate,
64 const OnMutedCallback& on_muted_callback); 64 const OnMutedCallback& on_muted_callback);
65 void StopFrameMonitoring(); 65 void StopFrameMonitoring();
66 66
67 private: 67 private:
(...skipping 15 matching lines...) Expand all
83 void StopFrameMonitoringOnIO(); 83 void StopFrameMonitoringOnIO();
84 84
85 // Compare |frame_counter_snapshot| with the current |frame_counter_|, and 85 // Compare |frame_counter_snapshot| with the current |frame_counter_|, and
86 // inform of the situation (muted, not muted) via |set_muted_state_callback|. 86 // inform of the situation (muted, not muted) via |set_muted_state_callback|.
87 void CheckFramesReceivedOnIO(const OnMutedCallback& set_muted_state_callback, 87 void CheckFramesReceivedOnIO(const OnMutedCallback& set_muted_state_callback,
88 uint64 old_frame_counter_snapshot); 88 uint64 old_frame_counter_snapshot);
89 89
90 // |thread_checker_| is bound to the main render thread. 90 // |thread_checker_| is bound to the main render thread.
91 base::ThreadChecker thread_checker_; 91 base::ThreadChecker thread_checker_;
92 92
93 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; 93 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
94 94
95 // |renderer_task_runner_| is used to ensure that 95 // |renderer_task_runner_| is used to ensure that
96 // VideoCaptureDeliverFrameCB is released on the main render thread. 96 // VideoCaptureDeliverFrameCB is released on the main render thread.
97 const scoped_refptr<base::SingleThreadTaskRunner> renderer_task_runner_; 97 const scoped_refptr<base::SingleThreadTaskRunner> renderer_task_runner_;
98 98
99 // VideoFrameResolutionAdapter is an inner class that is created on the main 99 // VideoFrameResolutionAdapter is an inner class that is created on the main
100 // render thread but operates on the IO-thread. It does the resolution 100 // render thread but operates on the IO-thread. It does the resolution
101 // adaptation and delivers frames to all registered tracks on the IO-thread. 101 // adaptation and delivers frames to all registered tracks on the IO-thread.
102 class VideoFrameResolutionAdapter; 102 class VideoFrameResolutionAdapter;
103 typedef std::vector<scoped_refptr<VideoFrameResolutionAdapter> > 103 typedef std::vector<scoped_refptr<VideoFrameResolutionAdapter> >
(...skipping 13 matching lines...) Expand all
117 117
118 // Frame rate configured on the video source, accessed on the IO-thread. 118 // Frame rate configured on the video source, accessed on the IO-thread.
119 float source_frame_rate_; 119 float source_frame_rate_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter); 121 DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter);
122 }; 122 };
123 123
124 } // namespace content 124 } // namespace content
125 125
126 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ 126 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl_manager_unittest.cc ('k') | content/renderer/media/video_track_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698