• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 IAUDIO_SOURCE_NODE_H_INCLUDED
18 #define IAUDIO_SOURCE_NODE_H_INCLUDED
19 
20 #include <BaseNode.h>
21 #include <ImsMediaAudioSource.h>
22 #include <IFrameCallback.h>
23 
24 /**
25  * @brief This class is interface between audio device and ims media packetization node
26  */
27 class IAudioSourceNode : public BaseNode, IFrameCallback
28 {
29 public:
30     IAudioSourceNode(BaseSessionCallback* callback = nullptr);
31     virtual ~IAudioSourceNode();
32     virtual kBaseNodeId GetNodeId();
33     virtual ImsMediaResult ProcessStart();
34     virtual void Stop();
35     virtual bool IsRunTime();
36     virtual bool IsRunTimeStart();
37     virtual bool IsSourceNode();
38     virtual void SetConfig(void* config);
39     virtual bool IsSameConfig(void* config);
40 
41     /**
42      * @brief Uplink callback of audio invoked when the audio read the valid audio frames from the
43      * device
44      *
45      * @param buffer The data frame
46      * @param size The size of the data frame
47      * @param timestamp The timestamp of the data in milliseconds unit.
48      * @param flag The flags of the frame
49      */
50     void onDataFrame(uint8_t* buffer, uint32_t size, int64_t timestamp, uint32_t flag);
51 
52     /**
53      * @brief Change the bitrate with given cmr value
54      *
55      * @param cmr The cmr value to change. The value will be 0-7 for AMR, or 0-8 for AMR-WB. CMR
56        value 15 indicates that no mode request is present, and other values are for future use.
57      */
58     void ProcessCmr(const uint32_t cmrType, const uint32_t cmrDefine = 0);
59 
60 public:
61     bool mFirstFrame;
62     std::unique_ptr<ImsMediaAudioSource> mAudioSource;
63     int32_t mCodecType;
64     uint32_t mCodecMode;
65     uint32_t mRunningCodecMode;
66     int8_t mPtime;
67     kEvsBandwidth mEvsBandwidth;
68     int8_t mSamplingRate;
69     int8_t mEvsChAwOffset;
70     int32_t mMediaDirection;
71     bool mIsDtxEnabled;
72     bool mIsOctetAligned;
73 };
74 
75 #endif
76