• 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_STREAM_GRAPH_RTP_TX_H
18 #define AUDIO_STREAM_GRAPH_RTP_TX_H
19 
20 #include <ImsMediaDefine.h>
21 #include <AudioStreamGraph.h>
22 #include <RtpHeaderExtension.h>
23 
24 class AudioStreamGraphRtpTx : public AudioStreamGraph
25 {
26 public:
27     AudioStreamGraphRtpTx(BaseSessionCallback* callback, int localFd = 0);
28     virtual ~AudioStreamGraphRtpTx();
29     virtual ImsMediaResult create(RtpConfig* config);
30     virtual ImsMediaResult update(RtpConfig* config);
31     virtual ImsMediaResult start();
32 
33     /**
34      * @brief Create a graph for send dtmf digit to network
35      *
36      * @param config AudioConfig for setting the parameters for nodes
37      * @param rtpEncoderNode The RtpEncoderNode instance to connect as a rear node after the
38      * DtmfSenderNode, if it is null, no dtmf packet will be delivered to RtpEncoderNode.
39      * @return true Returns when the graph created without error
40      * @return false Returns when the given parameters are invalid.
41      */
42     bool createDtmfGraph(RtpConfig* config, BaseNode* rtpEncoderNode);
43 
44     /**
45      * @brief Creates and send dtmf packet to the network through the node created
46      *
47      * @param digit A digit to send as a RtpEvent packet
48      * @param duration The milliseconds unit of duration how long to send the dtmf packet.
49      * @return true Returns true when the dtmf digit is sent without error.
50      * @return false Returns false when the dtmf digit cannot be sent to the node.
51      */
52     bool sendDtmf(char digit, int duration);
53 
54     /**
55      * @brief Set the cmr value to change the audio mode
56      *
57      * @param cmrType The 3 bit of cmr type for EVS and just cmr bit for AMR/AMR-WB codec
58      * @param cmrDefine The 4 bit of cmr define code for EVS and not used for AMR/AMR-WB codec
59      */
60     void processCmr(const uint32_t cmrType, const uint32_t cmrDefine = 0);
61 
62     /**
63      * @brief Send rtp header extension to the audio rtp
64      *
65      * @param listExtension The list of rtp header extension data
66      */
67     void sendRtpHeaderExtension(std::list<RtpHeaderExtension>* listExtension);
68 
69 private:
70     std::list<BaseNode*> mListDtmfNodes;
71 };
72 
73 #endif