1 /**
2  * Copyright (C) 2022 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 #ifndef VIDEO_SESSION_H
18 #define VIDEO_SESSION_H
19 
20 #include <ImsMediaDefine.h>
21 #include <BaseSession.h>
22 #include <VideoStreamGraphRtpTx.h>
23 #include <VideoStreamGraphRtpRx.h>
24 #include <VideoStreamGraphRtcp.h>
25 #include <RtpConfig.h>
26 #include <android/native_window.h>
27 
28 class VideoSession : public BaseSession
29 {
30 public:
31     VideoSession();
32     virtual ~VideoSession();
33     virtual SessionState getState();
34     virtual ImsMediaResult startGraph(RtpConfig* config);
35     // BaseSessionCallback
36     virtual void onEvent(int32_t type, uint64_t param1, uint64_t param2);
37 
38     /**
39      * @brief Set the preview surface
40      *
41      * @param surface The preview surface
42      * @return ImsMediaResult Returns RESULT_SUCCESS when the surface set properly, and returns
43      * RESULT_INVALID_PARAM when the parameter is not valid
44      */
45     ImsMediaResult setPreviewSurface(ANativeWindow* surface);
46 
47     /**
48      * @brief Set the display surface
49      *
50      * @param surface The preview surface
51      * @return ImsMediaResult Returns RESULT_SUCCESS when the surface set properly, and returns
52      * RESULT_INVALID_PARAM when the parameter is not valid
53      */
54     ImsMediaResult setDisplaySurface(ANativeWindow* surface);
55 
56     /**
57      * @brief Send internal event to process in the stream graph
58      *
59      * @param type The type of internal event defined in ImsMediaDefine.h
60      * @param param1 The additional parameter to set
61      * @param param2 The additional parameter to set
62      */
63     void SendInternalEvent(int32_t type, uint64_t param1, uint64_t param2);
64 
65 private:
66     VideoStreamGraphRtpTx* mGraphRtpTx;
67     VideoStreamGraphRtpRx* mGraphRtpRx;
68     VideoStreamGraphRtcp* mGraphRtcp;
69     ANativeWindow* mPreviewSurface;
70     ANativeWindow* mDisplaySurface;
71 };
72 
73 #endif