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

Side by Side Diff: webrtc/media/base/adaptedvideotracksource.h

Issue 2328333002: New class AdaptedVideoTrackSource. (Closed)
Patch Set: Allow VideoBroadcaster::wants() to be called from any thread. Created 4 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 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MEDIA_BASE_ADAPTEDVIDEOTRACKSOURCE_H_
12 #define WEBRTC_MEDIA_BASE_ADAPTEDVIDEOTRACKSOURCE_H_
13
14 #include "webrtc/api/mediastreaminterface.h"
15 #include "webrtc/api/notifier.h"
16 #include "webrtc/media/base/videoadapter.h"
17 #include "webrtc/media/base/videobroadcaster.h"
18
19 namespace rtc {
20
21 // Base class for sources which needs video adaptation, e.g., video
22 // capture sources. Sinks must be added and removed on one and only
23 // one thread, while AdaptFrame and OnFrame may be called on any
24 // thread.
25 class AdaptedVideoTrackSource
26 : public webrtc::Notifier<webrtc::VideoTrackSourceInterface> {
27 public:
28 AdaptedVideoTrackSource();
29
30 // Returns false if no stats are available, e.g, for a remote
31 // source, or a source which has not seen its first frame yet.
32 // Should avoid blocking.
33 bool GetStats(Stats* stats) override;
perkj_webrtc 2016/09/21 08:59:23 make this private too please.
nisse-webrtc 2016/09/21 09:43:59 Done.
34
35 protected:
36 // Checks the apply_rotation() flag. If the frame needs rotation, and it is a
37 // plain memory frame, it is rotated. Subclasses producing native frames must
38 // handle apply_rotation() themselves.
39 void OnFrame(const cricket::VideoFrame& frame);
40
41 // Reports the appropriate frame size after adaptation. Returns true
42 // if a frame is wanted. Returns false if there are no interested
43 // sinks, or if the VideoAdapter decides to drop the frame.
44 bool AdaptFrame(int width,
45 int height,
46 int64_t time_us,
47 int* out_width,
48 int* out_height,
49 int* crop_width,
50 int* crop_height,
51 int* crop_x,
52 int* crop_y);
53
54 // Returns the current value of the apply_rotation flag, derived
55 // from the VideoSinkWants of registered sinks. The value is derived
56 // from sinks' wants, in AddOrUpdateSink and RemoveSink. Beware that
57 // when using this method from a different thread, the value may
58 // become stale before it is used.
59 bool apply_rotation();
60
61 cricket::VideoAdapter* video_adapter() { return &video_adapter_; }
62
63 private:
64 // Implements rtc::VideoSourceInterface.
65 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
66 const rtc::VideoSinkWants& wants) override;
67 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
68
69 void OnSinkWantsChanged(const rtc::VideoSinkWants& wants);
70
71 rtc::ThreadChecker thread_checker_;
72
73 cricket::VideoAdapter video_adapter_;
74
75 rtc::CriticalSection stats_crit_;
76 rtc::Optional<Stats> stats_ GUARDED_BY(stats_crit_);
77
78 VideoBroadcaster broadcaster_;
79 };
80
81 } // namespace rtc
82
83 #endif // WEBRTC_MEDIA_BASE_ADAPTEDVIDEOTRACKSOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698