blob: 105843f3406d4606a73f3ab3aec8f9b7c166d0e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright 2017 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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_REF_COUNTED_VIDEO_SOURCE_PROVIDER_H_
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_REF_COUNTED_VIDEO_SOURCE_PROVIDER_H_
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "services/video_capture/public/mojom/device_factory_provider.mojom.h"
#include "services/video_capture/public/mojom/video_source_provider.mojom.h"
namespace content {
// Enables ref-counted shared ownership of a
// video_capture::mojom::DeviceFactoryPtr.
// Since instances of this class do not guarantee that the connection stays open
// for its entire lifetime, clients must verify that the connection is bound
// before using it.
class CONTENT_EXPORT RefCountedVideoSourceProvider
: public base::RefCounted<RefCountedVideoSourceProvider> {
public:
RefCountedVideoSourceProvider(
video_capture::mojom::VideoSourceProviderPtr source_provider,
video_capture::mojom::DeviceFactoryProviderPtr device_factory_provider,
base::OnceClosure destruction_cb);
base::WeakPtr<RefCountedVideoSourceProvider> GetWeakPtr();
const video_capture::mojom::VideoSourceProviderPtr& source_provider() {
return source_provider_;
}
void ShutdownServiceAsap();
void SetRetryCount(int32_t count);
void ReleaseProviderForTesting();
private:
friend class base::RefCounted<RefCountedVideoSourceProvider>;
~RefCountedVideoSourceProvider();
video_capture::mojom::VideoSourceProviderPtr source_provider_;
video_capture::mojom::DeviceFactoryProviderPtr device_factory_provider_;
base::OnceClosure destruction_cb_;
base::WeakPtrFactory<RefCountedVideoSourceProvider> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(RefCountedVideoSourceProvider);
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_REF_COUNTED_VIDEO_SOURCE_PROVIDER_H_
|