| Index: components/video_capture/public/cpp/stream_client_impl.h
|
| diff --git a/components/video_capture/public/cpp/stream_client_impl.h b/components/video_capture/public/cpp/stream_client_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9511704e7de2864465e4d2f6f885ed0ee64943af
|
| --- /dev/null
|
| +++ b/components/video_capture/public/cpp/stream_client_impl.h
|
| @@ -0,0 +1,68 @@
|
| +// Copyright 2016 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 COMPONENTS_VIDEO_CAPTURE_STREAM_SINK_H_
|
| +#define COMPONENTS_VIDEO_CAPTURE_STREAM_SINK_H_
|
| +
|
| +#include <map>
|
| +#include <vector>
|
| +
|
| +#include "base/callback_forward.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/time/time.h"
|
| +#include "components/video_capture/public/interfaces/video_capture.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +
|
| +namespace media {
|
| +class VideoFrame;
|
| +}
|
| +
|
| +namespace video_capture {
|
| +
|
| +// This class implements a simple sink for Stream frames. A video_capture client
|
| +// can construct one of these over a Stream in order to start receiving video
|
| +// frames from the stream.
|
| +//
|
| +// As each frame is received, the sink will call all of its frame callbacks
|
| +// (added via AddFrameCallback) with a corresponding media::VideoFrame object.
|
| +class StreamClientImpl : public mojom::StreamClient {
|
| + public:
|
| + using OnFrameReceivedCallback =
|
| + base::Callback<void(scoped_refptr<media::VideoFrame>)>;
|
| +
|
| + explicit StreamClientImpl(mojom::StreamPtr stream);
|
| +
|
| + ~StreamClientImpl() override;
|
| +
|
| + // Adds |callback| to the set of callbacks to notify each time a new frame
|
| + // arrives from the stream. All callbacks are always called from the thread
|
| + // on which the sink lives.
|
| + void AddOnFrameReceivedCallback(const OnFrameReceivedCallback& callback);
|
| +
|
| + private:
|
| + class FrameBuffer;
|
| +
|
| + // mojom::StreamClient
|
| + void FrameAvailable(mojom::FrameInfoPtr info,
|
| + const FrameAvailableCallback& callback) override;
|
| + void Error(const mojo::String& error) override;
|
| +
|
| + // A collection of callbacks to be notified every time a new video frame is
|
| + // received from the stream.
|
| + std::vector<OnFrameReceivedCallback> on_frame_received_callbacks_;
|
| +
|
| + mojo::Binding<mojom::StreamClient> binding_;
|
| +
|
| + mojom::StreamPtr stream_;
|
| +
|
| + base::TimeTicks first_frame_time_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(StreamClientImpl);
|
| +};
|
| +
|
| +} // namespace video_capture
|
| +
|
| +#endif // COMPONENTS_VIDEO_CAPTURE_STREAM_SINK_H_
|
|
|