From: John F. <jo...@us...> - 2011-01-10 17:09:41
|
Update of /cvsroot/ingex/ingex/player/http_IngexPlayer/client In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv29969/player/http_IngexPlayer/client Modified Files: HTTPPlayerClient.cpp HTTPPlayerClient.h Makefile test_HTTPPlayerClient.cpp Log Message: PlayerInput struct definition moved from duplicated LocalIngexPlayer.h and HTTPPlayerClient.h to IngexPlayer.h to resolve namespace differences between the two players. Index: HTTPPlayerClient.h =================================================================== RCS file: /cvsroot/ingex/ingex/player/http_IngexPlayer/client/HTTPPlayerClient.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HTTPPlayerClient.h 12 Jan 2010 17:11:36 -0000 1.2 --- HTTPPlayerClient.h 10 Jan 2011 17:09:30 -0000 1.3 *************** *** 2,6 **** * $Id$ * ! * Copyright (C) 2008-2009 British Broadcasting Corporation, All Rights Reserved * Author: Philip de Nier * Modifications: Matthew Marks --- 2,6 ---- * $Id$ * ! * Copyright (C) 2008-2010 British Broadcasting Corporation, All Rights Reserved * Author: Philip de Nier * Modifications: Matthew Marks *************** *** 39,82 **** { - - typedef enum - { - UNKNOWN_OUTPUT = 0, - /* playout to SDI via DVS card */ - DVS_OUTPUT, - /* auto-detect whether X11 X video extension is available, if not use plain X11 */ - X11_AUTO_OUTPUT, - /* playout to X11 window using X video extension*/ - X11_XV_OUTPUT, - /* playout to X11 window */ - X11_OUTPUT, - /* playout to both SDI and X11 window (auto-detect availability of Xv) */ - DUAL_DVS_AUTO_OUTPUT, - /* playout to both SDI and X11 window */ - DUAL_DVS_X11_OUTPUT, - /* playout to both SDI and X11 X video extension window */ - DUAL_DVS_X11_XV_OUTPUT - } PlayerOutputType; - - typedef enum - { - MXF_INPUT = 1, - RAW_INPUT, - DV_INPUT, - FFMPEG_INPUT, - SHM_INPUT, - UDP_INPUT, - BALLS_INPUT, - BLANK_INPUT, - CLAPPER_INPUT - } PlayerInputType; - - typedef struct - { - PlayerInputType type; - std::string name; - std::map<std::string, std::string> options; - } PlayerInput; - /* options for each PlayerInputType are as follows: --- 39,42 ---- *************** *** 158,169 **** /* setting the output type will cause the the player to be stop()ped and restarted when start() is called again */ ! void setOutputType(PlayerOutputType outputType, float scale); void setDVSTarget(int card, int channel); /* returns the output type used */ ! PlayerOutputType getOutputType(); /* same as getOutputType(), except it returns the actual output type if an auto type is used */ /* eg. if X11_AUTO_OUTPUT is set then returns either X11_XV_OUTPUT or X11_OUTPUT */ ! PlayerOutputType getActualOutputType(); /* sets the video split type (see ingex_player/video_switch_sink.h for enum values) when start() is called again */ --- 118,129 ---- /* setting the output type will cause the the player to be stop()ped and restarted when start() is called again */ ! void setOutputType(prodauto::PlayerOutputType outputType, float scale); void setDVSTarget(int card, int channel); /* returns the output type used */ ! prodauto::PlayerOutputType getOutputType(); /* same as getOutputType(), except it returns the actual output type if an auto type is used */ /* eg. if X11_AUTO_OUTPUT is set then returns either X11_XV_OUTPUT or X11_OUTPUT */ ! prodauto::PlayerOutputType getActualOutputType(); /* sets the video split type (see ingex_player/video_switch_sink.h for enum values) when start() is called again */ *************** *** 173,176 **** --- 133,141 ---- void setSDIOSDEnable(bool enable); + void setPixelAspectRatio(Rational *aspect); /* default: 1/1 */ + void setNumAudioLevelMonitors(int num); /* default: 2 */ + void setApplyScaleFilter(bool enable); /* default: true */ + void showProgressBar(bool show); + HTTPPlayerState getState(); *************** *** 186,190 **** /* opens the files/sources and start playing */ ! bool start(std::vector<PlayerInput> inputs, bool startPaused, int64_t startPosition); /* functions inherited from IngexPlayerListenerRegistry */ --- 151,155 ---- /* opens the files/sources and start playing */ ! bool start(std::vector<prodauto::PlayerInput> inputs, std::vector<bool>& opened, bool startPaused, int64_t startPosition); /* functions inherited from IngexPlayerListenerRegistry */ *************** *** 233,238 **** bool sendSimpleCommand(std::string command); bool sendSimpleCommand(std::string command, std::map<std::string, std::string> args); ! bool sendJSONCommand(std::string command, std::string jsonString); ! bool sendJSONInfoCommand(std::string command, std::string* jsonString); pthread_mutex_t _connectionMutex; --- 198,204 ---- bool sendSimpleCommand(std::string command); bool sendSimpleCommand(std::string command, std::map<std::string, std::string> args); ! bool JSONPost(std::string command, std::string jsonString); ! bool JSONGet(std::string command, std::string* jsonString); ! bool JSONPostReceive(std::string command, std::string jsonSend, std::string* jsonResult); pthread_mutex_t _connectionMutex; Index: Makefile =================================================================== RCS file: /cvsroot/ingex/ingex/player/http_IngexPlayer/client/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 12 Oct 2009 16:06:27 -0000 1.2 --- Makefile 10 Jan 2011 17:09:30 -0000 1.3 *************** *** 41,45 **** DEPENDENCIES = $(patsubst %.cpp,.deps/%.d,$(SOURCES)) ! SERVER_OBJECTS = $(SERVER_DIR)/.objs/JSONObject.o $(SERVER_DIR)/.objs/Utilities.o $(SERVER_DIR)/.objs/HTTPPlayerState.o LIBDIRS += -L$(JOGSHUTTLE_DIR) --- 41,46 ---- DEPENDENCIES = $(patsubst %.cpp,.deps/%.d,$(SOURCES)) ! SERVER_OBJECTS = $(SERVER_DIR)/.objs/JSONObject.o $(SERVER_DIR)/.objs/Utilities.o $(SERVER_DIR)/.objs/HTTPPlayerState.o \ ! $(SERVER_DIR)/.objs/IngexException.o LIBDIRS += -L$(JOGSHUTTLE_DIR) Index: test_HTTPPlayerClient.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/player/http_IngexPlayer/client/test_HTTPPlayerClient.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_HTTPPlayerClient.cpp 24 Feb 2009 08:21:17 -0000 1.1 --- test_HTTPPlayerClient.cpp 10 Jan 2011 17:09:30 -0000 1.2 *************** *** 2,6 **** * $Id$ * ! * Copyright (C) 2008-2009 British Broadcasting Corporation, All Rights Reserved * Author: Philip de Nier * --- 2,6 ---- * $Id$ * ! * Copyright (C) 2008-2010 British Broadcasting Corporation, All Rights Reserved * Author: Philip de Nier * *************** *** 236,241 **** { int cmdlnIndex = 1; ! vector<PlayerInput> inputs; ! PlayerInput input; string serverName = g_defaultServerHostName; int serverPort = g_defaultServerPort; --- 236,241 ---- { int cmdlnIndex = 1; ! vector<prodauto::PlayerInput> inputs; ! prodauto::PlayerInput input; string serverName = g_defaultServerHostName; int serverPort = g_defaultServerPort; *************** *** 313,317 **** return 1; } ! input.type = MXF_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); --- 313,317 ---- return 1; } ! input.type = prodauto::MXF_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); *************** *** 327,331 **** return 1; } ! input.type = RAW_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); --- 327,331 ---- return 1; } ! input.type = prodauto::RAW_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); *************** *** 341,345 **** return 1; } ! input.type = DV_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); --- 341,345 ---- return 1; } ! input.type = prodauto::DV_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); *************** *** 355,359 **** return 1; } ! input.type = FFMPEG_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); --- 355,359 ---- return 1; } ! input.type = prodauto::FFMPEG_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); *************** *** 369,373 **** return 1; } ! input.type = SHM_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); --- 369,373 ---- return 1; } ! input.type = prodauto::SHM_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); *************** *** 383,387 **** return 1; } ! input.type = UDP_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); --- 383,387 ---- return 1; } ! input.type = prodauto::UDP_INPUT; input.name = argv[cmdlnIndex + 1]; inputs.push_back(input); *************** *** 391,395 **** else if (strcmp(argv[cmdlnIndex], "--balls") == 0) { ! input.type = BALLS_INPUT; input.name = ""; inputs.push_back(input); --- 391,395 ---- else if (strcmp(argv[cmdlnIndex], "--balls") == 0) { ! input.type = prodauto::BALLS_INPUT; input.name = ""; inputs.push_back(input); *************** *** 399,403 **** else if (strcmp(argv[cmdlnIndex], "--blank") == 0) { ! input.type = BLANK_INPUT; input.name = ""; inputs.push_back(input); --- 399,403 ---- else if (strcmp(argv[cmdlnIndex], "--blank") == 0) { ! input.type = prodauto::BLANK_INPUT; input.name = ""; inputs.push_back(input); *************** *** 407,411 **** else if (strcmp(argv[cmdlnIndex], "--clapper") == 0) { ! input.type = CLAPPER_INPUT; input.name = ""; inputs.push_back(input); --- 407,411 ---- else if (strcmp(argv[cmdlnIndex], "--clapper") == 0) { ! input.type = prodauto::CLAPPER_INPUT; input.name = ""; inputs.push_back(input); *************** *** 474,492 **** if (dualOutput) { ! player->setOutputType(DUAL_DVS_AUTO_OUTPUT, 1.0); printf("Set output to DUAL\n"); } else if (dvsOutput) { ! player->setOutputType(DVS_OUTPUT, 1.0); printf("Set output to DVS\n"); } else { ! player->setOutputType(X11_AUTO_OUTPUT, 1.0); printf("Set output to X11\n"); } ! CHECK(player->start(inputs, false, 0)); printf("Started\n"); --- 474,493 ---- if (dualOutput) { ! player->setOutputType(prodauto::DUAL_DVS_AUTO_OUTPUT, 1.0); printf("Set output to DUAL\n"); } else if (dvsOutput) { ! player->setOutputType(prodauto::DVS_OUTPUT, 1.0); printf("Set output to DVS\n"); } else { ! player->setOutputType(prodauto::X11_AUTO_OUTPUT, 1.0); printf("Set output to X11\n"); } ! std::vector<bool> opened; ! CHECK(player->start(inputs, opened, false, 0)); printf("Started\n"); Index: HTTPPlayerClient.cpp =================================================================== RCS file: /cvsroot/ingex/ingex/player/http_IngexPlayer/client/HTTPPlayerClient.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTTPPlayerClient.cpp 24 Feb 2009 08:21:17 -0000 1.1 --- HTTPPlayerClient.cpp 10 Jan 2011 17:09:30 -0000 1.2 *************** *** 2,6 **** * $Id$ * ! * Copyright (C) 2008-2009 British Broadcasting Corporation, All Rights Reserved * Author: Philip de Nier * --- 2,6 ---- * $Id$ * ! * Copyright (C) 2008-2010 British Broadcasting Corporation, All Rights Reserved * Author: Philip de Nier * *************** *** 162,169 **** } - - - - HTTPPlayerClient::HTTPPlayerClient() : _curl(0), _port(0), _statePollInterval(g_defaultStatePollInterval), _pollThreadId(0), _stopPollThread(true) --- 162,165 ---- *************** *** 289,293 **** } ! void HTTPPlayerClient::setOutputType(PlayerOutputType outputType, float scale) { LOCK_SECTION(&_connectionMutex); --- 285,289 ---- } ! void HTTPPlayerClient::setOutputType(prodauto::PlayerOutputType outputType, float scale) { LOCK_SECTION(&_connectionMutex); *************** *** 325,329 **** } ! PlayerOutputType HTTPPlayerClient::getOutputType() { LOCK_SECTION(&_connectionMutex); --- 321,325 ---- } ! prodauto::PlayerOutputType HTTPPlayerClient::getOutputType() { LOCK_SECTION(&_connectionMutex); *************** *** 332,342 **** { fprintf(stderr, "Command failed: not connected\n"); ! return UNKNOWN_OUTPUT; } ! return UNKNOWN_OUTPUT; } ! PlayerOutputType HTTPPlayerClient::getActualOutputType() { LOCK_SECTION(&_connectionMutex); --- 328,338 ---- { fprintf(stderr, "Command failed: not connected\n"); ! return prodauto::UNKNOWN_OUTPUT; } ! return prodauto::UNKNOWN_OUTPUT; } ! prodauto::PlayerOutputType HTTPPlayerClient::getActualOutputType() { LOCK_SECTION(&_connectionMutex); *************** *** 345,352 **** { fprintf(stderr, "Command failed: not connected\n"); ! return UNKNOWN_OUTPUT; } ! return UNKNOWN_OUTPUT; } --- 341,348 ---- { fprintf(stderr, "Command failed: not connected\n"); ! return prodauto::UNKNOWN_OUTPUT; } ! return prodauto::UNKNOWN_OUTPUT; } *************** *** 385,388 **** --- 381,454 ---- } + void HTTPPlayerClient::setPixelAspectRatio(Rational *aspect) + { + LOCK_SECTION(&_connectionMutex); + + if (!isConnected()) + { + fprintf(stderr, "Command failed: not connected\n"); + return; + } + + string cmd = "settings/setpixelaspectratio"; + map<string, string> args; + args.insert(pair<string, string>("num", int_to_string(aspect->num))); + args.insert(pair<string, string>("den", int_to_string(aspect->den))); + + sendSimpleCommand(cmd, args); + } + + void HTTPPlayerClient::setNumAudioLevelMonitors(int num) + { + LOCK_SECTION(&_connectionMutex); + + if (!isConnected()) + { + fprintf(stderr, "Command failed: not connected\n"); + return; + } + + string cmd = "settings/setnumaudiolevelmonitors"; + map<string, string> args; + args.insert(pair<string, string>("number", int_to_string(num))); + + sendSimpleCommand(cmd, args); + } + + void HTTPPlayerClient::setApplyScaleFilter(bool enable) + { + LOCK_SECTION(&_connectionMutex); + + if (!isConnected()) + { + fprintf(stderr, "Command failed: not connected\n"); + return; + } + + string cmd = "settings/setapplyscalefilter"; + map<string, string> args; + args.insert(pair<string, string>("enable", bool_to_string(enable))); + + sendSimpleCommand(cmd, args); + } + + void HTTPPlayerClient::showProgressBar(bool show) + { + LOCK_SECTION(&_connectionMutex); + + if (!isConnected()) + { + fprintf(stderr, "Command failed: not connected\n"); + return; + } + + string cmd = "settings/showprogressbar"; + map<string, string> args; + args.insert(pair<string, string>("show", bool_to_string(show))); + + sendSimpleCommand(cmd, args); + } + + HTTPPlayerState HTTPPlayerClient::getState() { *************** *** 428,432 **** } ! bool HTTPPlayerClient::start(vector<PlayerInput> inputs, bool startPaused, int64_t startPosition) { LOCK_SECTION(&_connectionMutex); --- 494,498 ---- } ! bool HTTPPlayerClient::start(std::vector<prodauto::PlayerInput> inputs, std::vector<bool>& opened, bool startPaused, int64_t startPosition) { LOCK_SECTION(&_connectionMutex); *************** *** 443,450 **** JSONArray* inputsArray = json.setArray("inputs"); ! vector<PlayerInput>::const_iterator inputsIter; for (inputsIter = inputs.begin(); inputsIter != inputs.end(); inputsIter++) { ! const PlayerInput& input = *inputsIter; JSONObject* inputObject = inputsArray->appendObject(); --- 509,516 ---- JSONArray* inputsArray = json.setArray("inputs"); ! vector<prodauto::PlayerInput>::const_iterator inputsIter; for (inputsIter = inputs.begin(); inputsIter != inputs.end(); inputsIter++) { ! const prodauto::PlayerInput& input = *inputsIter; JSONObject* inputObject = inputsArray->appendObject(); *************** *** 466,473 **** } ! if (!sendJSONCommand("start", json.toString())) { return false; } return true; --- 532,566 ---- } ! std::string result; ! if (!JSONPostReceive("start", json.toString(), &result)) ! { ! return false; ! } ! int parseIndex = 0; ! JSONObject* jsonResult = JSONObject::parse(result.c_str(), &parseIndex); ! if (jsonResult == 0) { + fprintf(stderr, "Failed to parse string to JSON object\n"); return false; } + JSONArray* openedArray = jsonResult->getArrayValue("opened"); + if (openedArray == 0) + { + fprintf(stderr, "Failed to find opened array in JSON object\n"); + return false; + } + opened.clear(); + vector<JSONValue*>::const_iterator iter; + JSONBool* jsonBool; + for (iter = openedArray->getValue().begin(); iter != openedArray->getValue().end(); iter++) + { + jsonBool = dynamic_cast<JSONBool*>(*iter); + if (jsonBool == 0) + { + fprintf(stderr, "Failed to find JSONBool in JSON array\n"); + return false; + } + opened.push_back(jsonBool->getValue()); + } return true; *************** *** 1205,1209 **** jsonString.clear(); ! if (sendJSONInfoCommand("info/state.json", &jsonString)) { parseIndex = 0; --- 1298,1302 ---- jsonString.clear(); ! if (JSONGet("info/state.json", &jsonString)) { parseIndex = 0; *************** *** 1354,1358 **** } ! bool HTTPPlayerClient::sendJSONCommand(string command, string jsonString) { curl_easy_reset(_curl); --- 1447,1451 ---- } ! bool HTTPPlayerClient::JSONPost(std::string command, std::string jsonString) { curl_easy_reset(_curl); *************** *** 1384,1388 **** } ! bool HTTPPlayerClient::sendJSONInfoCommand(std::string command, std::string* jsonString) { curl_easy_reset(_curl); --- 1477,1481 ---- } ! bool HTTPPlayerClient::JSONGet(std::string command, std::string* jsonString) { curl_easy_reset(_curl); *************** *** 1412,1413 **** --- 1505,1542 ---- return true; } + + bool HTTPPlayerClient::JSONPostReceive(std::string command, std::string jsonSend, std::string* jsonResult) + { + curl_easy_reset(_curl); + + snprintf(_urlBuffer, sizeof(_urlBuffer), "http://%s:%d/%s", _hostName.c_str(), _port, command.c_str()); + + struct curl_slist* slist = NULL; + slist = curl_slist_append(slist, "Content-Type: application/json"); + + string stringResult; + stringResult.reserve(512); + + char errorBuffer[CURL_ERROR_SIZE]; + curl_easy_setopt(_curl, CURLOPT_ERRORBUFFER, errorBuffer); + curl_easy_setopt(_curl, CURLOPT_NOPROGRESS, 1); + curl_easy_setopt(_curl, CURLOPT_URL, _urlBuffer); + curl_easy_setopt(_curl, CURLOPT_POST, 1); + curl_easy_setopt(_curl, CURLOPT_HTTPHEADER, slist); + curl_easy_setopt(_curl, CURLOPT_POSTFIELDS, jsonSend.c_str()); + curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, receive_json_data); + curl_easy_setopt(_curl, CURLOPT_WRITEDATA, (void*)&stringResult); + + + CURLcode result = curl_easy_perform(_curl); + curl_slist_free_all(slist); + + if (result != 0) + { + fprintf(stderr, "Failed to send json command '%s': %s\n", _urlBuffer, errorBuffer); + return false; + } + + *jsonResult = stringResult; + return true; + } |