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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/**
* 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 AUDIO_SESSION_H
#define AUDIO_SESSION_H
#include <ImsMediaDefine.h>
#include <BaseSession.h>
#include <AudioStreamGraphRtpTx.h>
#include <AudioStreamGraphRtpRx.h>
#include <AudioStreamGraphRtcp.h>
#include <RtpConfig.h>
#include <MediaQualityAnalyzer.h>
#include <list>
class AudioSession : public BaseSession
{
public:
AudioSession();
virtual ~AudioSession();
virtual SessionState getState();
virtual void onEvent(int32_t type, uint64_t param1, uint64_t param2);
virtual void setMediaQualityThreshold(const MediaQualityThreshold& threshold);
virtual ImsMediaResult startGraph(RtpConfig* config);
/**
* @brief Add and start stream graph instance of the session. It has to be called only to
* create new StreamGraph should be added with different RtpConfig as a argument.
*
* @param config The parameters to operate nodes in the StreamGraph.
* @param enableRtcp {@code true} when the rtcp needs to be enabled to the rest of the graphs
* @return ImsMediaResult result of create or start graph. If the result has no error, it
* returns RESULT_SUCCESS. check #ImsMediaDefine.h.
*/
ImsMediaResult addGraph(RtpConfig* config, bool enableRtcp);
/**
* @brief Determine to remain only one StreamGraph instance and remove other StreamGraph.
* If the target StreamGraph is not in RUN state, call start instance to change to
* RUN state. when the call session is converted to confirmed session. It has to be
* called with proper RtpConfig argument that can choose the StreamGraph with the
* config. If there is no matched StreamGraph with same RtpConfig, it returns failure
* of RESULT_INVALID_PARAM.
*
* @param config The parameters to operate nodes in the StreamGraph.
* @return ImsMediaResult result of create or start graph. If the result has no error, it
* returns RESULT_SUCCESS. check #ImsMediaDefine.h.
*/
ImsMediaResult confirmGraph(RtpConfig* config);
/**
* @brief Delete a StreamGraph which has a matched RtpConfig argument.
*
* @param config A parameter to find the matching StreamGraph instance.
* @return ImsMediaResult A result of deleting StreamGraph instance. If the result has
* no error, it returns RESULT_SUCCESS. check #ImsMediaDefine.h.
*/
ImsMediaResult deleteGraph(RtpConfig* config);
/**
* @brief Send Dtmf digit to the network
*
* @param digit A digit character
* @param duration The duration of millisecond unit indicate how long to send the digit as a rtp
* event packet
*/
void sendDtmf(char digit, int duration);
/**
* @brief Send internal event to process in the stream graph
*
* @param type The type of internal event defined in ImsMediaDefine.h
* @param param1 The additional parameter to set
* @param param2 The additional parameter to set
*/
void SendInternalEvent(int32_t type, uint64_t param1, uint64_t param2);
/**
* @brief Check whether the graph has the same remote address or not
*
* @param config The RtpConfig to check the remote address
*/
bool IsGraphAlreadyExist(RtpConfig* config);
private:
std::list<AudioStreamGraphRtpTx*> mListGraphRtpTx;
std::list<AudioStreamGraphRtpRx*> mListGraphRtpRx;
std::list<AudioStreamGraphRtcp*> mListGraphRtcp;
std::unique_ptr<MediaQualityAnalyzer> mMediaQualityAnalyzer;
};
#endif
|