RDK Documentation (Open Sourced RDK Components)
hdmiin_shim.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2021 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 /**
21  * @file hdmiin_shim.cpp
22  * @brief shim for dispatching UVE HDMI input playback
23  */
24 #include "hdmiin_shim.h"
25 #include "priv_aamp.h"
26 #include <stdlib.h>
27 #include <string.h>
28 #include <pthread.h>
29 #include <signal.h>
30 #include <assert.h>
31 #include "AampUtils.h"
32 
33 /**
34 * HdmiInput thunder plugin reference: https://wiki.rdkcentral.com/display/RDK/HDMI++Input
35 */
36 
37 #define HDMIINPUT_CALLSIGN "org.rdk.HdmiInput.1"
38 
39 /**
40  * @brief StreamAbstractionAAMP_HDMIIN Constructor
41  */
43  : StreamAbstractionAAMP_VIDEOIN("HDMIIN", HDMIINPUT_CALLSIGN,logObj,aamp,seek_pos,rate)
44 {
45  aamp->SetContentType("HDMI_IN");
46 }
47 
48 /**
49  * @brief StreamAbstractionAAMP_HDMIIN Destructor
50  */
52 {
53  AAMPLOG_WARN("destructor ");
54 }
55 
56 /**
57  * @brief Initialize a newly created object.
58  */
60 {
62  retval = InitHelper(tuneType);
63 
64 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
65  std::function<void(const WPEFramework::Core::JSON::VariantContainer&)> videoInfoUpdatedMethod = std::bind(&StreamAbstractionAAMP_HDMIIN::OnVideoStreamInfoUpdate, this, std::placeholders::_1);
66  RegisterEvent("videoStreamInfoUpdate", videoInfoUpdatedMethod);
67 #endif
68  return retval;
69 }
70 
71 /**
72  * @brief Starts streaming.
73  */
75 {
76  const char *url = aamp->GetManifestUrl().c_str();
77  int hdmiInputPort = -1;
78  if( sscanf(url, "hdmiin://localhost/deviceid/%d", &hdmiInputPort ) == 1 )
79  {
80  StartHelper(hdmiInputPort,"startHdmiInput");
81  }
82 }
83 
84 /**
85  * @brief Stops streaming.
86  */
87 void StreamAbstractionAAMP_HDMIIN::Stop(bool clearChannelData)
88 {
89  StopHelper("stopHdmiInput");
90 }
91 
92 /**
93  * @brief To get the available video tracks.
94  * @return available video tracks
95  */
97 { // STUB
98  AAMPLOG_WARN("StreamAbstractionAAMP_HDMIIN");
99  return std::vector<StreamInfo*>();
100 }
101 
102 /**
103  * @brief To get the available thumbnail tracks.
104  * @return available thumbnail tracks
105  */
107 { // STUB
108  AAMPLOG_WARN("StreamAbstractionAAMP_HDMIIN");
109  return std::vector<StreamInfo*>();
110 }
111 
112 /**
113  * @brief To set the thumbnail track by index.
114  * @return True or False indicating success failure.
115  */
117 {
118  (void)thumbnailIndex; /* unused */
119  return false;
120 }
121 
122 /**
123  * @brief To get thumbnail range data.
124  * @return vector containg multiple thumbnail tile info.
125  */
126 std::vector<ThumbnailData> StreamAbstractionAAMP_HDMIIN::GetThumbnailRangeData(double start, double end, std::string *baseurl, int *raw_w, int *raw_h, int *width, int *height)
127 {
128  return std::vector<ThumbnailData>();
129 }
130 
131 
132 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
133 
134 /**
135  * @brief Gets videoStreamInfoUpdate event and translates into aamp events
136  */
137 void StreamAbstractionAAMP_HDMIIN::OnVideoStreamInfoUpdate(const JsonObject& parameters)
138 {
139  std::string message;
140  parameters.ToString(message);
141  AAMPLOG_WARN("%s",message.c_str());
142 
143  JsonObject videoInfoObj = parameters;
144  VideoScanType videoScanType = (videoInfoObj["progressive"].Boolean() ? eVIDEOSCAN_PROGRESSIVE : eVIDEOSCAN_INTERLACED);
145 
146  double frameRate = 0.0;
147  double frameRateN = static_cast<double> (videoInfoObj["frameRateN"].Number());
148  double frameRateD = static_cast<double> (videoInfoObj["frameRateD"].Number());
149  if((0 != frameRateN) && (0 != frameRateD))
150  frameRate = frameRateN / frameRateD;
151 
152  aamp->NotifyBitRateChangeEvent(0, eAAMP_BITRATE_CHANGE_BY_HDMIIN, videoInfoObj["width"].Number(), videoInfoObj["height"].Number(), frameRate, 0, false, videoScanType, 0, 0);
153 }
154 #endif
HDMIINPUT_CALLSIGN
#define HDMIINPUT_CALLSIGN
Definition: hdmiin_shim.cpp:37
eVIDEOSCAN_PROGRESSIVE
@ eVIDEOSCAN_PROGRESSIVE
Definition: AampEvent.h:192
PrivateInstanceAAMP::SetContentType
void SetContentType(const char *contentType)
Set Content Type.
Definition: priv_aamp.cpp:6121
TuneType
TuneType
Tune Typea.
Definition: priv_aamp.h:190
StreamAbstractionAAMP::aamp
PrivateInstanceAAMP * aamp
Definition: StreamAbstractionAAMP.h:727
StreamAbstractionAAMP_HDMIIN::GetThumbnailRangeData
std::vector< ThumbnailData > GetThumbnailRangeData(double, double, std::string *, int *, int *, int *, int *) override
To get thumbnail range data.
Definition: hdmiin_shim.cpp:126
StreamAbstractionAAMP_HDMIIN::GetAvailableVideoTracks
std::vector< StreamInfo * > GetAvailableVideoTracks(void) override
To get the available video tracks.
Definition: hdmiin_shim.cpp:96
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
PrivateInstanceAAMP::GetManifestUrl
std::string & GetManifestUrl(void)
Get manifest URL.
Definition: priv_aamp.h:1890
VideoScanType
VideoScanType
VideoScanType - Progressive/Interlaced.
Definition: AampEvent.h:190
StreamAbstractionAAMP_VIDEOIN::StartHelper
void StartHelper(int port, const std::string &methodName)
calls start on video in specified by port and method name
Definition: videoin_shim.cpp:113
StreamAbstractionAAMP_HDMIIN::~StreamAbstractionAAMP_HDMIIN
~StreamAbstractionAAMP_HDMIIN()
StreamAbstractionAAMP_HDMIIN Destructor.
Definition: hdmiin_shim.cpp:51
eAAMPSTATUS_OK
@ eAAMPSTATUS_OK
Definition: priv_aamp.h:207
StreamAbstractionAAMP_HDMIIN::Stop
void Stop(bool clearChannelData) override
Stops streaming.
Definition: hdmiin_shim.cpp:87
priv_aamp.h
Private functions and types used internally by AAMP.
StreamAbstractionAAMP_VIDEOIN::StopHelper
void StopHelper(const std::string &methodName)
Stops streaming.
Definition: videoin_shim.cpp:129
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
StreamAbstractionAAMP_HDMIIN::SetThumbnailTrack
bool SetThumbnailTrack(int) override
To set the thumbnail track by index.
Definition: hdmiin_shim.cpp:116
AAMPStatusType
AAMPStatusType
AAMP Function return values.
Definition: priv_aamp.h:205
StreamAbstractionAAMP_HDMIIN::Init
AAMPStatusType Init(TuneType tuneType) override
Initialize a newly created object.
Definition: hdmiin_shim.cpp:59
StreamAbstractionAAMP_HDMIIN::StreamAbstractionAAMP_HDMIIN
StreamAbstractionAAMP_HDMIIN(AampLogManager *logObj, class PrivateInstanceAAMP *aamp, double seekpos, float rate)
StreamAbstractionAAMP_HDMIIN Constructor.
Definition: hdmiin_shim.cpp:42
StreamAbstractionAAMP_HDMIIN::Start
void Start() override
Starts streaming.
Definition: hdmiin_shim.cpp:74
hdmiin_shim.h
shim for dispatching UVE HDMI input playback
PrivateInstanceAAMP::NotifyBitRateChangeEvent
void NotifyBitRateChangeEvent(int bitrate, BitrateChangeReason reason, int width, int height, double framerate, double position, bool GetBWIndex=false, VideoScanType scantype=eVIDEOSCAN_UNKNOWN, int aspectRatioWidth=0, int aspectRatioHeight=0)
Notify bit rate change event to listeners.
Definition: priv_aamp.cpp:2538
StreamAbstractionAAMP_VIDEOIN
Fragment collector for MPEG DASH.
Definition: videoin_shim.h:42
StreamAbstractionAAMP_HDMIIN::GetAvailableThumbnailTracks
std::vector< StreamInfo * > GetAvailableThumbnailTracks(void) override
To get the available thumbnail tracks.
Definition: hdmiin_shim.cpp:106
eVIDEOSCAN_INTERLACED
@ eVIDEOSCAN_INTERLACED
Definition: AampEvent.h:193