• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: rtsp package
15  * Author: dingkang
16  * Create: 2022-01-24
17  */
18 
19 #ifndef LIBCASTENGINE_RTSP_PACKAGE_H
20 #define LIBCASTENGINE_RTSP_PACKAGE_H
21 
22 #include <string>
23 
24 #include "rtsp_basetype.h"
25 #include "rtsp_parse.h"
26 #include "rtsp_param_info.h"
27 
28 namespace OHOS {
29 namespace CastEngine {
30 namespace CastEngineService {
31 namespace CastSessionRtsp {
32 class RtspEncap {
33 public:
RtspEncap()34     RtspEncap() {}
~RtspEncap()35     ~RtspEncap() {}
36 
37     static std::string EncapAnnounce(const std::string &algStr, int curSeq, int version);
38     static std::string EncapRequestOption(int curSeq);
39     static std::string EncapRequestGetParameter(ParamInfo &param, int curSeq);
40     static std::string EncapSetParameterM4Request(ParamInfo &negParam, double version, const std::string &ip, int seq);
41     static std::string EncapActionRequest(ActionType actionType, double version, int curSeq);
42     static std::string EncapSetupRequest(int cseq, const std::string &uri, int port);
43     static std::string EncapPlayRequest(int cseq, const std::string &uri, int port);
44     static std::string EncapTearDownRequest(int cseq, const std::string &uri);
45     static std::string EncapPauseRequest(int cseq, const std::string &uri);
46     static std::string EncapKeepAliveRequest(int curSeq, double version);
47     static std::string EncapEventChangeRequest(int moduleId, int event, const std::string &param, double version,
48         int curSeq);
49     static std::string EncapSetParamRequestM11(int cseq, const std::string &uri, int trigger);
50     static std::string EncapCastRenderReadyRequest(int cseq, const std::string &uri, int readyFlag);
51     static std::string EncapCommonResponse(RtspParse &request, const std::string &statusCode);
52     static std::string EncapSetupResponse(ParamInfo &param, int cseq, int serverPort, int remotectlPort, int rtcpPort);
53     static std::string EncapResponseOption(double version, int curSeq);
54     static std::string EncapResponseGetParamM3(ParamInfo &clientParam, RtspParse &request, int seq);
55     static void EncapResponseGetParamM3Body(ParamInfo &clientParam, const std::string &getParam, std::string &body);
56     static void EncapUibc(std::string &body, ParamInfo &negParam);
57     static void EncapFeature(std::string &body, ParamInfo &negParam);
58     static std::string SetVideoAndAudioCodecsParameter(ParamInfo &negParam);
59     static std::string SetAudioParameter(ParamInfo &negParam);
60     static void SetAnotherParameter(ParamInfo &negParam, double version, const std::string &ip, std::string &body);
61 
62 private:
63     static std::string AddRequestHeaders(int curSeq);
64     static std::string AddResponseHeaders(const std::string &statusCode, int curSeq);
65     static std::string GetNowDate();
66     static std::string GetMediaCapability(ParamInfo &inputParam);
67     static std::string GetPlayerControllerCapability(ParamInfo &inputParam);
68     static std::string GetInputCategoryList(const RemoteControlParamInfo &paramInfo);
69     static void EncapGenericCapList(std::string &body, const RemoteControlParamInfo &paramInfo);
70     static void EncapHidcCapList(std::string &body, const RemoteControlParamInfo &paramInfo);
71     static void EncapVendorCapList(std::string &body, const RemoteControlParamInfo &paramInfo);
72 };
73 } // namespace CastSessionRtsp
74 } // namespace CastEngineService
75 } // namespace CastEngine
76 } // namespace OHOS
77 
78 #endif
79