summaryrefslogtreecommitdiff
path: root/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/include/audio/nodes/IAudioSourceNode.h
blob: 741556b0d0c73a4b74b7ec59869e8646b782bb4f (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef IAUDIO_SOURCE_NODE_H_INCLUDED
#define IAUDIO_SOURCE_NODE_H_INCLUDED

#include <BaseNode.h>
#include <ImsMediaAudioSource.h>
#include <IFrameCallback.h>

/**
 * @brief This class is interface between audio device and ims media packetization node
 */
class IAudioSourceNode : public BaseNode, IFrameCallback
{
public:
    IAudioSourceNode(BaseSessionCallback* callback = nullptr);
    virtual ~IAudioSourceNode();
    virtual kBaseNodeId GetNodeId();
    virtual ImsMediaResult ProcessStart();
    virtual void Stop();
    virtual bool IsRunTime();
    virtual bool IsRunTimeStart();
    virtual bool IsSourceNode();
    virtual void SetConfig(void* config);
    virtual bool IsSameConfig(void* config);

    /**
     * @brief Uplink callback of audio invoked when the audio read the valid audio frames from the
     * device
     *
     * @param buffer The data frame
     * @param size The size of the data frame
     * @param timestamp The timestamp of the data in milliseconds unit.
     * @param flag The flags of the frame
     */
    void onDataFrame(uint8_t* buffer, uint32_t size, int64_t timestamp, uint32_t flag);

    /**
     * @brief Change the bitrate with given cmr value
     *
     * @param cmr The cmr value to change. The value will be 0-7 for AMR, or 0-8 for AMR-WB. CMR
       value 15 indicates that no mode request is present, and other values are for future use.
     */
    void ProcessCmr(uint32_t cmr);

public:
    bool mFirstFrame;
    std::unique_ptr<ImsMediaAudioSource> mAudioSource;
    int32_t mCodecType;
    uint32_t mCodecMode;
    uint32_t mRunningCodecMode;
    int8_t mPtime;
    kEvsBandwidth mEvsBandwidth;
    int8_t mSamplingRate;
    int8_t mEvsChAwOffset;
    int32_t mMediaDirection;
    bool mIsDtxEnabled;
    bool mIsOctetAligned;
};

#endif