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

Unified Diff: content/renderer/media/video_track_adapter.h

Issue 246433006: Change MediaStreamVideoSource to output different resolutions to different tracks depending on the … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/video_track_adapter.h
diff --git a/content/renderer/media/video_track_adapter.h b/content/renderer/media/video_track_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e54e8c199a281c2d3fb732bfa42531bdff3bc22
--- /dev/null
+++ b/content/renderer/media/video_track_adapter.h
@@ -0,0 +1,79 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
+#define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "content/renderer/media/media_stream_video_track.h"
+#include "media/base/video_frame.h"
+
+namespace content {
+
+// VideoTrackAdapter is a helper class used by MediaStreamVideoSource used for
+// adapting the video resolution from a source implementation to the resolution
+// a track requires. Different tracks can have different resolution constraints.
+// The constraints can be set as max width and height as well as max and min
+// aspect ratio.
+// Video frames are delivered to a track using a VideoCaptureDeliverFrameCB on
+// the IO-thread.
+// Adaptations is done by wrapping the original media::VideoFrame in a new
+// media::VideoFrame with a new visible_rect and natural_size.
+class VideoTrackAdapter
mcasas 2014/05/07 14:10:43 I seem to understand from VideoTrackAdapter struct
perkj_chrome 2014/05/08 11:29:47 Not sure what you mean. It can only change the res
+ : public base::RefCountedThreadSafe<VideoTrackAdapter> {
+ public:
+ explicit VideoTrackAdapter(
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
+
+ // Register |track| to receive video frames in |frame_callback| with
+ // a resolution within the boundaries of the arguments.
+ // Must be called on the main render thread.
+ void AddTrack(MediaStreamVideoTrack* track,
+ VideoCaptureDeliverFrameCB frame_callback,
+ int max_width, int max_height,
+ double min_aspect_ratio,
+ double max_aspect_ratio);
+ void RemoveTrack(MediaStreamVideoTrack* track);
+
+ // Delivers |frame| to all tracks that have registered a callback.
+ // Must be called on the IO-thread.
+ void DeliverFrameOnIO(
+ const scoped_refptr<media::VideoFrame>& frame,
+ const media::VideoCaptureFormat& format);
+
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
+ return io_message_loop_;
+ }
+
+ private:
+ virtual ~VideoTrackAdapter();
+ friend class base::RefCountedThreadSafe<VideoTrackAdapter>;
+
+ void AddTrackOnIO(MediaStreamVideoTrack* track,
+ VideoCaptureDeliverFrameCB frame_callback,
+ int max_width, int max_height,
+ double min_aspect_ratio,
+ double max_aspect_ratio);
+ void RemoveTrackOnIO(MediaStreamVideoTrack* track);
+
+ base::ThreadChecker thread_checker_;
+ scoped_refptr<base::MessageLoopProxy> io_message_loop_;
+
+ // VideoFrameResolutionAdapter is an inner class that is created on the main
+ // render thread but operates on the IO-thread. It does the resolution
+ // adaptation and delivers frames to all registered tracks on the IO-thread.
+ class VideoFrameResolutionAdapter;
+ typedef std::vector<scoped_refptr<VideoFrameResolutionAdapter> >
mcasas 2014/05/07 14:10:43 std::list? Seems that you only used it for push_ba
perkj_chrome 2014/05/08 11:29:47 vector seems to be prefered in Chrome. Its far mor
+ FrameAdapters;
+ FrameAdapters adapters_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698