• 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 AUDIO_SESSION_H
18 #define AUDIO_SESSION_H
19 
20 #include <ImsMediaDefine.h>
21 #include <BaseSession.h>
22 #include <AudioStreamGraphRtpTx.h>
23 #include <AudioStreamGraphRtpRx.h>
24 #include <AudioStreamGraphRtcp.h>
25 #include <RtpConfig.h>
26 #include <MediaQualityAnalyzer.h>
27 #include <RtpHeaderExtension.h>
28 #include <list>
29 
30 class AudioSession : public BaseSession
31 {
32 public:
33     AudioSession();
34     virtual ~AudioSession();
35     virtual SessionState getState();
36     virtual void onEvent(int32_t type, uint64_t param1, uint64_t param2);
37     virtual void setMediaQualityThreshold(const MediaQualityThreshold& threshold);
38     virtual ImsMediaResult startGraph(RtpConfig* config);
39 
40     /**
41      * @brief Add and start stream graph instance of the session. It has to be called only to
42      *        create new StreamGraph should be added with different RtpConfig as a argument.
43      *
44      * @param config The parameters to operate nodes in the StreamGraph.
45      * @param enableRtcp {@code true} when the rtcp needs to be enabled to the rest of the graphs
46      * @return ImsMediaResult result of create or start graph. If the result has no error, it
47      *         returns RESULT_SUCCESS. check #ImsMediaDefine.h.
48      */
49     ImsMediaResult addGraph(RtpConfig* config, bool enableRtcp);
50 
51     /**
52      * @brief Determine to remain only one StreamGraph instance and remove other StreamGraph.
53      *        If the target StreamGraph is not in RUN state, call start instance to change to
54      *        RUN state. when the call session is converted to confirmed session. It has to be
55      *        called with proper RtpConfig argument that can choose the StreamGraph with the
56      *        config. If there is no matched StreamGraph with same RtpConfig, it returns failure
57      *        of RESULT_INVALID_PARAM.
58      *
59      * @param config The parameters to operate nodes in the StreamGraph.
60      * @return ImsMediaResult result of create or start graph. If the result has no error, it
61      *         returns RESULT_SUCCESS. check #ImsMediaDefine.h.
62      */
63     ImsMediaResult confirmGraph(RtpConfig* config);
64 
65     /**
66      * @brief Delete a StreamGraph which has a matched RtpConfig argument.
67      *
68      * @param config A parameter to find the matching StreamGraph instance.
69      * @return ImsMediaResult A result of deleting StreamGraph instance. If the result has
70      *         no error, it returns RESULT_SUCCESS. check #ImsMediaDefine.h.
71      */
72     ImsMediaResult deleteGraph(RtpConfig* config);
73 
74     /**
75      * @brief Send Dtmf digit to the network
76      *
77      * @param digit A digit character
78      * @param duration The duration of millisecond unit indicate how long to send the digit as a rtp
79      * event packet
80      */
81     void sendDtmf(char digit, int duration);
82 
83     /**
84      * @brief Send internal event to process in the stream graph
85      *
86      * @param type The type of internal event defined in ImsMediaDefine.h
87      * @param param1 The additional parameter to set
88      * @param param2 The additional parameter to set
89      */
90     void SendInternalEvent(int32_t type, uint64_t param1, uint64_t param2);
91 
92     /**
93      * @brief Check whether the graph has the same remote address or not
94      *
95      * @param config The RtpConfig to check the remote address
96      */
97     bool IsGraphAlreadyExist(RtpConfig* config);
98 
99     /**
100      * @brief Get graph list size with repective stream type
101      *
102      * @param type The graph type to fetch
103      * @return uint32_t The size of list
104      */
105     uint32_t getGraphSize(ImsMediaStreamType type);
106 
107     /**
108      * @brief Send rtp header extension to the audio rtp
109      *
110      * @param listExtension The list of rtp header extension data
111      */
112     void sendRtpHeaderExtension(std::list<RtpHeaderExtension>* listExtension);
113 
114 private:
115     std::list<AudioStreamGraphRtpTx*> mListGraphRtpTx;
116     std::list<AudioStreamGraphRtpRx*> mListGraphRtpRx;
117     std::list<AudioStreamGraphRtcp*> mListGraphRtcp;
118     std::unique_ptr<MediaQualityAnalyzer> mMediaQualityAnalyzer;
119 };
120 
121 #endif