- controlapi: add audio to API (/control/audio)
- neutrinoapi: add some new function for streaming infos

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@479 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
yjogol
2010-03-13 09:12:31 +00:00
parent f779a33337
commit 6c49e36d50
5 changed files with 61 additions and 33 deletions

View File

@@ -169,12 +169,13 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]=
{"startplugin", &CControlAPI::StartPluginCGI, "text/plain"},
{"exec", &CControlAPI::ExecCGI, "+xml"},
{"yweb", &CControlAPI::YWebCGI, "text/plain"},
// video handling
// video & Audio handling
{"aspectratio", &CControlAPI::AspectRatioCGI, "text/plain"},
{"videoformat", &CControlAPI::VideoFormatCGI, "text/plain"},
{"videooutput", &CControlAPI::VideoOutputCGI, "text/plain"},
{"vcroutput", &CControlAPI::VCROutputCGI, "text/plain"},
{"scartmode", &CControlAPI::ScartModeCGI, "text/plain"},
{"audio", &CControlAPI::AudioCGI, "text/plain"},
// timer
{"timer", &CControlAPI::TimerCGI, "text/plain"},
// bouquet editing
@@ -740,6 +741,16 @@ void CControlAPI::ScartModeCGI(CyhookHandler *hh)
hh->SendOk();
}
//-----------------------------------------------------------------------------
void CControlAPI::AudioCGI(CyhookHandler *hh)
{
if (hh->ParamList.empty() || hh->ParamList["1"] == "info") {
hh->printf("%s",(NeutrinoAPI->getAudioInfoAsString()).c_str());
return;
}
//TODO: more
}
//-------------------------------------------------------------------------
void CControlAPI::VolumeCGI(CyhookHandler *hh)
{

View File

@@ -83,6 +83,7 @@ private:
void VideoOutputCGI(CyhookHandler *hh);
void VCROutputCGI(CyhookHandler *hh);
void ScartModeCGI(CyhookHandler *hh);
void AudioCGI(CyhookHandler *hh);
void setBouquetCGI(CyhookHandler *hh);
void saveBouquetCGI(CyhookHandler *hh);
void moveBouquetCGI(CyhookHandler *hh);

View File

@@ -16,6 +16,7 @@
#include <string>
#include <fstream>
#include <map>
#include <sstream>
// tuxbox
#include <neutrinoMessages.h>
@@ -99,6 +100,8 @@ std::string CNeutrinoAPI::Dbox_Hersteller[4] = {"none", "Nokia", "Philips", "Sag
std::string CNeutrinoAPI::videooutput_names[5] = {"CVBS", "RGB with CVBS", "S-Video", "YUV with VBS", "YUV with CVBS"};
std::string CNeutrinoAPI::videoformat_names[5] = {"automatic", "4:3", "14:9", "16:9", "20:9"};
std::string CNeutrinoAPI::audiotype_names[5] = {"none", "single channel","dual channel","joint stereo","stereo"};
std::string CNeutrinoAPI::mpegmodes[] = { "stereo", "joint_st", "dual_ch", "single_ch" };
std::string CNeutrinoAPI::ddmodes[] = { "CH1/CH2", "C", "L/R", "L/C/R", "L/R/S", "L/C/R/S", "L/R/SL/SR", "L/C/R/SL/SR" };
//=============================================================================
// Constructor & Destructor
@@ -416,7 +419,7 @@ std::string CNeutrinoAPI::getVideoAspectRatioAsString(void) {
//-------------------------------------------------------------------------
int CNeutrinoAPI::setVideoAspectRatioAsString(std::string newRatioString) {
int newRatioInt = -1;
for(int i=0;i<sizeof(videoformat_names);i++)
for(int i=0;i<(int)sizeof(videoformat_names);i++)
if( videoformat_names[i] == newRatioString){
newRatioInt = i;
break;
@@ -425,3 +428,38 @@ int CNeutrinoAPI::setVideoAspectRatioAsString(std::string newRatioString) {
videoDecoder->setAspectRatio(newRatioInt, -1);
return newRatioInt;
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getVideoResolutionAsString(void) {
int xres, yres, framerate;
videoDecoder->getPictureInfo(xres, yres, framerate);
std::stringstream out;
out << xres << "x" << yres;
return out.str();
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getVideoFramerateAsString(void) {
int xres, yres, framerate;
std::string sframerate="unknown";
videoDecoder->getPictureInfo(xres, yres, framerate);
switch(framerate){
case 2:
sframerate="25fps";break;
case 5:
sframerate="50fps";break;
}
return sframerate;
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getAudioInfoAsString(void) {
int type, layer, freq, mode, lbitrate;
audioDecoder->getAudioInfo(type, layer, freq, lbitrate, mode);
std::stringstream out;
if(type == 0)
out << "MPEG " << mpegmodes[mode] << " (" << freq <<")";
else
out << "DD " << ddmodes[mode] << " (" << freq <<")";
return out.str();
}

View File

@@ -48,6 +48,8 @@ class CNeutrinoAPI
static std::string videooutput_names[5];
static std::string videoformat_names[5];
static std::string audiotype_names[5];
static std::string mpegmodes[];
static std::string ddmodes[];
// get functions to collect data
bool GetChannelEvents(void);
@@ -70,6 +72,9 @@ class CNeutrinoAPI
std::string timerEventRepeat2Str(CTimerd::CTimerEventRepeat rep);
std::string getVideoAspectRatioAsString(void);
int setVideoAspectRatioAsString(std::string newRatioString);
std::string getVideoResolutionAsString(void);
std::string getVideoFramerateAsString(void);
std::string getAudioInfoAsString(void);
public:
CNeutrinoAPI();
~CNeutrinoAPI(void);

View File

@@ -660,7 +660,6 @@ std::string CNeutrinoYParser::func_get_boxtype(CyhookHandler *, std::string)
//-------------------------------------------------------------------------
std::string CNeutrinoYParser::func_get_current_stream_info(CyhookHandler *hh, std::string)
{
int bitInfo[10];
CZapitClient::CCurrentServiceInfo serviceinfo;
serviceinfo = NeutrinoAPI->Zapit->getCurrentServiceInfo();
@@ -674,37 +673,11 @@ std::string CNeutrinoYParser::func_get_current_stream_info(CyhookHandler *hh, s
hh->ParamList["tsfrequency"] = string_printf("%d.%d MHz", serviceinfo.tsfrequency/1000, serviceinfo.tsfrequency%1000);
hh->ParamList["polarisation"] = serviceinfo.polarisation==1?"h":"v";
hh->ParamList["ServiceName"] = NeutrinoAPI->GetServiceName(live_channel_id);//NeutrinoAPI->Zapit->getCurrentServiceID());
NeutrinoAPI->GetStreamInfo(bitInfo);
hh->ParamList["VideoFormat"] = string_printf("%d x %d", bitInfo[0], bitInfo[1] );
hh->ParamList["BitRate"] = string_printf("%d\n", bitInfo[4]*50);
hh->ParamList["VideoFormat"] = NeutrinoAPI->getVideoResolutionAsString();
// hh->ParamList["BitRate"] = NeutrinoAPI->getVideoFramerateAsString();
hh->ParamList["AspectRatio"] = NeutrinoAPI->getVideoAspectRatioAsString();
switch ( bitInfo[3] ) //fps
{
case 3: hh->ParamList["FPS"] = "25"; break;
case 6: hh->ParamList["FPS"] = "50"; break;
default: hh->ParamList["FPS"]= "unknown";
}
if (!bitInfo[7]) hh->ParamList["AudioType"]="unknown";
else {
const char* layernames[4]={"res","III","II","I"};
const char* sampfreqnames[4]={"44,1k","48k","32k","res"};
const char* modenames[4]={"stereo","joint_st","dual_ch","single_ch"};
long header = bitInfo[7];
unsigned char layer = (header>>17)&3;
unsigned char sampfreq =(header>>10)&3;
unsigned char mode = (header>> 6)&3;
unsigned char copy = (header>> 3)&1;
hh->ParamList["AudioType"] =
string_printf("%s (%s/%s) %s", modenames[mode], sampfreqnames[sampfreq],
layernames[layer], copy?"c":"");
}
hh->ParamList["FPS"] = NeutrinoAPI->getVideoFramerateAsString();
hh->ParamList["AudioType"] = NeutrinoAPI->getAudioInfoAsString();
return "";
}
//-------------------------------------------------------------------------