OLD | NEW |
---|---|
(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 class AdaptedVideoTrackSource | |
perkj_webrtc
2016/09/20 12:26:10
Can you add a not about how this class should be u
nisse-webrtc
2016/09/20 13:17:47
Done.
| |
22 : public webrtc::Notifier<webrtc::VideoTrackSourceInterface> { | |
23 public: | |
24 AdaptedVideoTrackSource(); | |
25 | |
26 // Returns false if no stats are available, e.g, for a remote | |
27 // source, or a source which has not seen its first frame yet. | |
28 // Should avoid blocking. | |
29 bool GetStats(Stats* stats) override; | |
perkj_webrtc
2016/09/20 12:26:10
All these methods should be made private. An imple
nisse-webrtc
2016/09/20 13:17:47
Done. I'll never get used to this convention.
| |
30 | |
31 // Implements rtc::VideoSourceInterface | |
32 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | |
33 const rtc::VideoSinkWants& wants) override; | |
34 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; | |
35 | |
36 protected: | |
37 // Checks the apply_rotation_ flag. If the frame needs rotation, it | |
38 // will be rotated if it is a plain memory frame, and discarded it | |
39 // if it is a native frame. (Subclasses producing native frames must | |
40 // handle applied_rotation themselves). | |
41 void OnFrame(const cricket::VideoFrame& frame); | |
42 | |
43 void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); | |
perkj_webrtc
2016/09/20 12:26:10
private
nisse-webrtc
2016/09/20 13:17:47
Done.
| |
44 | |
45 // Reports the appropriate frame size after adaptation. Returns true | |
46 // if a frame is wanted. Returns false if there are no interested | |
47 // sinks, or if the VideoAdapter decides to drop the frame. | |
48 bool AdaptFrame(int width, | |
49 int height, | |
50 int64_t time_us, | |
51 int* out_width, | |
52 int* out_height, | |
53 int* crop_width, | |
54 int* crop_height, | |
55 int* crop_x, | |
56 int* crop_y); | |
57 | |
58 // Returns the current value of the apply_rotation flag, derived | |
59 // from the VideoSinkWants of registered sinks. Beware that when | |
60 // using this method, the value may become stale before it is used. | |
perkj_webrtc
2016/09/20 12:26:10
mm-ok. the problem is not really appy_rotation()-
| |
61 bool apply_rotation(); | |
62 | |
63 cricket::VideoAdapter* video_adapter() { return &video_adapter_; } | |
64 | |
65 private: | |
66 rtc::ThreadChecker thread_checker_; | |
67 | |
68 cricket::VideoAdapter video_adapter_; | |
69 | |
70 rtc::CriticalSection apply_rotation_crit_; | |
71 bool apply_rotation_ GUARDED_BY(apply_rotation_crit_); | |
72 | |
73 rtc::CriticalSection stats_crit_; | |
74 rtc::Optional<Stats> stats_ GUARDED_BY(stats_crit_); | |
75 | |
76 VideoBroadcaster broadcaster_; | |
77 }; | |
78 | |
79 } // namespace rtc | |
80 | |
81 #endif // WEBRTC_MEDIA_BASE_ADAPTEDVIDEOTRACKSOURCE_H_ | |
OLD | NEW |