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 IVIDEO_SOURCE_NODE_H_INCLUDED
18 #define IVIDEO_SOURCE_NODE_H_INCLUDED
19 
20 #include <BaseNode.h>
21 #include <ImsMediaVideoSource.h>
22 #include <android/native_window.h>
23 #include <mutex>
24 
25 /**
26  * @brief This class is interface between audio device and ims media packetization node
27  */
28 class IVideoSourceNode : public BaseNode, IVideoSourceCallback
29 {
30 public:
31     IVideoSourceNode(BaseSessionCallback* callback = nullptr);
32     virtual ~IVideoSourceNode();
33     virtual kBaseNodeId GetNodeId();
34     virtual ImsMediaResult Start();
35     virtual void Stop();
36     virtual bool IsRunTime();
37     virtual bool IsSourceNode();
38     virtual void SetConfig(void* config);
39     virtual bool IsSameConfig(void* config);
40     virtual ImsMediaResult UpdateConfig(void* config);
41     virtual void ProcessData();
42 
43     /**
44      * @brief Updates preview surface
45      *
46      * @param window surface buffer to update
47      */
48     void UpdateSurface(ANativeWindow* window);
49 
50     /**
51      * @brief Set the bitrate threshold to notify the indication when the encoding video bitrate is
52      * less than the threshold values
53      *
54      * @param bitrate The video encoding bitrate in bps unit
55      */
56     void SetBitrateThreshold(int32_t bitrate);
57     // callback from ImsMediaVideoSource
58     virtual void OnUplinkEvent(uint8_t* pBitstream, uint32_t nSize, int64_t pstUsec, uint32_t flag);
59     virtual void OnEvent(int32_t type, int32_t param1, int32_t param2);
60 
61 protected:
62     std::unique_ptr<ImsMediaVideoSource> mVideoSource;
63     std::mutex mMutex;
64     uint32_t mCodecType;
65     uint32_t mVideoMode;
66     uint32_t mCodecProfile;
67     uint32_t mCodecLevel;
68     uint32_t mCameraId;
69     uint32_t mCameraZoom;
70     uint32_t mWidth;
71     uint32_t mHeight;
72     uint32_t mFramerate;
73     uint32_t mBitrate;
74     int8_t mSamplingRate;
75     uint32_t mIntraInterval;
76     android::String8 mImagePath;
77     uint32_t mDeviceOrientation;
78     ANativeWindow* mWindow;
79     int32_t mMinBitrateThreshold;
80     bool mBitrateNotified;
81 };
82 
83 #endif