1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <memory>
20 
21 #include "common/libs/fs/shared_fd.h"
22 #include "host/frontend/webrtc/display_handler.h"
23 #include "host/frontend/webrtc/lib/connection_observer.h"
24 #include "https/RunLoop.h"
25 
26 namespace cuttlefish {
27 
28 class CfConnectionObserverFactory
29     : public cuttlefish::webrtc_streaming::ConnectionObserverFactory {
30  public:
31   CfConnectionObserverFactory(cuttlefish::SharedFD touch_fd,
32                               cuttlefish::SharedFD keyboard_fd);
33   ~CfConnectionObserverFactory() override = default;
34 
35   std::shared_ptr<cuttlefish::webrtc_streaming::ConnectionObserver> CreateObserver()
36       override;
37 
38   void SetDisplayHandler(std::weak_ptr<DisplayHandler> display_handler);
39 
40  private:
41   cuttlefish::SharedFD touch_fd_;
42   cuttlefish::SharedFD keyboard_fd_;
43   std::weak_ptr<DisplayHandler> weak_display_handler_;
44   std::shared_ptr<RunLoop> run_loop_;
45   std::thread run_loop_thread_;
46 };
47 
48 }  // namespace cuttlefish
49