| Index: media/capture/service/video_capture_handler_impl.h
|
| diff --git a/media/capture/service/video_capture_handler_impl.h b/media/capture/service/video_capture_handler_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7d5a83a73a78f07df38c3877bfa0bfec0f6af8c2
|
| --- /dev/null
|
| +++ b/media/capture/service/video_capture_handler_impl.h
|
| @@ -0,0 +1,84 @@
|
| +// 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 MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
|
| +#define MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/system_monitor/system_monitor.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "media/capture/interfaces/video_capture.mojom.h"
|
| +#include "media/capture/video/video_capture_device.h"
|
| +
|
| +namespace media {
|
| +class VideoCaptureDeviceFactory;
|
| +}
|
| +
|
| +namespace mojo {
|
| +class ApplicationImpl;
|
| +}
|
| +
|
| +namespace media {
|
| +
|
| +class StreamImpl;
|
| +
|
| +// Implementation of the VideoCaptureHandler interface. This is the main top-
|
| +// level service exposed by the video_capture app, used to acquire handles to
|
| +// specific Stream objects. This class is single threaded throughout.
|
| +// We're a DevicesChangedObserver to reenumerate on device change.
|
| +class VideoCaptureHandlerImpl
|
| + : public mojom::VideoCaptureHandler,
|
| + public base::SystemMonitor::DevicesChangedObserver {
|
| + public:
|
| + explicit VideoCaptureHandlerImpl(mojo::ApplicationImpl* app);
|
| + ~VideoCaptureHandlerImpl() override;
|
| +
|
| + private:
|
| + friend class VideoCaptureHandlerImplTest;
|
| + friend class VideoCaptureTest;
|
| +
|
| + // mojom::VideoCaptureHandler:
|
| + void RequestMediaDevices(
|
| + const RequestMediaDevicesCallback& callback) override;
|
| + void RequestStream(mojom::StreamOptionsPtr options,
|
| + const mojo::String& security_origin,
|
| + const RequestStreamCallback& callback) override;
|
| +
|
| + // base::SystemMonitor::DevicesChangedObserver
|
| + void OnDevicesChanged(base::SystemMonitor::DeviceType device_type) override;
|
| +
|
| + // Receives the results of devices enumeration and updates |device_names_|.
|
| + void OnVideoCaptureDevicesEnumerated(
|
| + scoped_ptr<media::VideoCaptureDevice::Names> device_names);
|
| +
|
| + void OnStart(const std::string& id);
|
| + void OnStopOrError(const std::string& id);
|
| +
|
| + mojo::ApplicationImpl* const app_;
|
| +
|
| + const scoped_ptr<media::VideoCaptureDeviceFactory>
|
| + video_capture_device_factory_;
|
| + scoped_ptr<media::VideoCaptureDevice::Names> device_names_;
|
| +
|
| + // Table mapping "public" device id to private device id.
|
| + std::map<std::string, std::string> public_to_private_id_map_;
|
| +
|
| + // Table mapping (public/private) id and its implementation objects.
|
| + using DeviceAndStream =
|
| + std::pair<scoped_ptr<media::VideoCaptureDevice>, scoped_ptr<StreamImpl>>;
|
| + std::map<std::string, DeviceAndStream> device_and_streams_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + base::WeakPtrFactory<VideoCaptureHandlerImpl> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(VideoCaptureHandlerImpl);
|
| +};
|
| +
|
| +} // namespace media
|
| +
|
| +#endif // MEDIA_CAPTURE_SERVICE_VIDEO_CAPTURE_HANDLER_IMPL_H_
|
|
|