Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_VIDEO_CAPTURE_STREAM_SINK_H_ | |
| 6 #define COMPONENTS_VIDEO_CAPTURE_STREAM_SINK_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/time/time.h" | |
| 16 #include "components/video_capture/public/interfaces/video_capture.mojom.h" | |
| 17 #include "mojo/public/cpp/bindings/binding.h" | |
| 18 | |
| 19 namespace media { | |
| 20 class VideoFrame; | |
| 21 } | |
| 22 | |
| 23 namespace video_capture { | |
| 24 | |
| 25 // This class implements a simple sink for Stream frames. A video_capture client | |
| 26 // can construct one of these over a Stream in order to start receiving video | |
| 27 // frames from the stream. | |
| 28 // | |
| 29 // As each frame is received, the sink will call all of its frame callbacks | |
| 30 // (added via AddFrameCallback) with a corresponding media::VideoFrame object. | |
| 31 class StreamClientImpl : public mojom::StreamClient { | |
|
Ken Rockot(use gerrit already)
2016/02/12 21:29:51
nit: One of the nice advantages of stashing all mo
| |
| 32 public: | |
| 33 using OnFrameReceivedCallback = | |
| 34 base::Callback<void(scoped_refptr<media::VideoFrame>)>; | |
| 35 | |
| 36 explicit StreamClientImpl(mojom::StreamPtr stream); | |
| 37 | |
| 38 ~StreamClientImpl() override; | |
| 39 | |
| 40 // Adds |callback| to the set of callbacks to notify each time a new frame | |
| 41 // arrives from the stream. All callbacks are always called from the thread | |
| 42 // on which the sink lives. | |
| 43 void AddOnFrameReceivedCallback(const OnFrameReceivedCallback& callback); | |
|
emircan
2016/02/16 17:45:48
I like this idea generally. However, giving multip
mcasas
2016/02/16 23:17:21
After discussing with rockot@, I think I'm removin
| |
| 44 | |
| 45 private: | |
| 46 // mojom::StreamClient | |
| 47 void FrameAvailable(mojom::FrameInfoPtr info, | |
| 48 const FrameAvailableCallback& callback) override; | |
| 49 void Error(const mojo::String& error) override; | |
| 50 | |
| 51 // A collection of callbacks to be notified every time a new video frame is | |
| 52 // received from the stream. | |
| 53 std::vector<OnFrameReceivedCallback> on_frame_received_callbacks_; | |
| 54 | |
| 55 mojo::Binding<mojom::StreamClient> binding_; | |
| 56 | |
| 57 mojom::StreamPtr stream_; | |
| 58 | |
| 59 base::TimeTicks first_frame_time_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(StreamClientImpl); | |
| 62 }; | |
| 63 | |
| 64 } // namespace video_capture | |
| 65 | |
| 66 #endif // COMPONENTS_VIDEO_CAPTURE_STREAM_SINK_H_ | |
| OLD | NEW |