From 7fe60435bce6595a9c58a9bfd8244d74b5320e96 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Jan 2013 08:46:13 +0100 Subject: Import DirectFB141_2k11R3_beta5 --- Source/DirectFB/tools/voodooplay_client.c | 317 ++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100755 Source/DirectFB/tools/voodooplay_client.c (limited to 'Source/DirectFB/tools/voodooplay_client.c') diff --git a/Source/DirectFB/tools/voodooplay_client.c b/Source/DirectFB/tools/voodooplay_client.c new file mode 100755 index 0000000..6a97309 --- /dev/null +++ b/Source/DirectFB/tools/voodooplay_client.c @@ -0,0 +1,317 @@ +/* + (c) Copyright 2001-2010 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + This file is subject to the terms and conditions of the MIT License: + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + +static const char *m_name; +static bool m_launch_app; +static u8 m_launch_app_uuid[16]; +static u8 m_launch_player_uuid[16]; +static bool m_stop_instance; +static u8 m_stop_instance_uuid[16]; +static bool m_wait_instance; +static u8 m_wait_instance_uuid[16]; + +/**********************************************************************************************************************/ + +static DFBBoolean parse_command_line( int argc, char *argv[] ); + +/**********************************************************************************************************************/ + +static DirectEnumerationResult +player_callback( void *ctx, + const VoodooPlayInfo *info, + const VoodooPlayVersion *version, + const char *address, + unsigned int ms_since_last_seen ) +{ + DirectResult ret; + int i; + char buf[33]; + char buf2[33]; + char buf3[33]; + + snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + info->uuid[0], info->uuid[1], info->uuid[2], info->uuid[3], info->uuid[4], + info->uuid[5], info->uuid[6], info->uuid[7], info->uuid[8], info->uuid[9], + info->uuid[10], info->uuid[11], info->uuid[12], info->uuid[13], info->uuid[14], + info->uuid[15] ); + + D_INFO( "Voodoo/Play: <%4ums> [ %-30s ] { %s } %s%s\n", + ms_since_last_seen, info->name, buf, address, (info->flags & VPIF_LEVEL2) ? " *" : "" ); + + DirectFBSetOption( "remote", address ); + + IVoodooPlayer *player; + + ret = VoodooPlayerCreate( &player ); + if (ret) { + D_DERROR( ret, "Voodoo/Play/Client: VoodooPlayerCreate() failed!\n" ); + return DENUM_OK; + } + + + + VoodooAppDescription apps[100]; + unsigned int num; + + ret = player->GetApps( player, 100, &num, apps ); + if (ret) { + D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::GetApps() failed!\n" ); + player->Release( player ); + return DENUM_OK; + } + + for (i=0; i launching on %s!\n", buf ); + + ret = player->LaunchApp( player, m_launch_app_uuid, m_launch_player_uuid, instance_uuid ); + if (ret) + D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::LaunchApp() failed!\n" ); + + snprintf( buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + instance_uuid[0], instance_uuid[1], instance_uuid[2], instance_uuid[3], instance_uuid[4], + instance_uuid[5], instance_uuid[6], instance_uuid[7], instance_uuid[8], instance_uuid[9], + instance_uuid[10], instance_uuid[11], instance_uuid[12], instance_uuid[13], instance_uuid[14], + instance_uuid[15] ); + + D_INFO( " => instance UUID is %s!\n", buf ); + } + } + + + + VoodooAppInstanceDescription instances[100]; + + ret = player->GetInstances( player, 100, &num, instances ); + if (ret) { + D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::GetInstances() failed!\n" ); + player->Release( player ); + return DENUM_OK; + } + + for (i=0; i stopping!\n" ); + + ret = player->StopInstance( player, m_stop_instance_uuid ); + if (ret) + D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::StopInstance() failed!\n" ); + } + + if (m_wait_instance && !memcmp( m_wait_instance_uuid, instances[i].uuid, 16 )) { + D_INFO( " -> waiting!\n" ); + + ret = player->WaitInstance( player, m_wait_instance_uuid ); + if (ret) + D_DERROR( ret, "Voodoo/Play/Client: IVoodooPlayer::WaitInstance() failed!\n" ); + } + } + + + player->Release( player ); + + return DENUM_OK; +} + +int +main( int argc, char *argv[] ) +{ + DFBResult ret; + VoodooPlayInfo info; + VoodooPlayer *player = NULL; + + /* Initialize DirectFB including command line parsing. */ + ret = DirectFBInit( &argc, &argv ); + if (ret) { + DirectFBError( "DirectFBInit() failed", ret ); + return -1; + } + + /* Parse the command line. */ + if (!parse_command_line( argc, argv )) + return -2; + + if (m_name) { + direct_snputs( info.name, m_name, VOODOO_PLAYER_NAME_LENGTH ); + } + + ret = voodoo_player_create( m_name ? &info : NULL, &player ); + if (ret) { + D_ERROR( "Voodoo/Play: Could not create the player (%s)!\n", DirectFBErrorString(ret) ); + goto out; + } + + + voodoo_player_broadcast( player ); + + sleep( 1 ); + + voodoo_player_enumerate( player, player_callback, NULL ); + + +out: + if (player) + voodoo_player_destroy( player ); + + return ret; +} + +/**********************************************************************************************************************/ + +static DFBBoolean +print_usage( const char *name ) +{ + fprintf( stderr, "Usage: %s [-n ] [-l app_uuid player_uuid] [-s instance_uuid] [-w instance_uuid]\n", name ); + + return DFB_FALSE; +} + +static DFBBoolean +parse_command_line( int argc, char *argv[] ) +{ + int i; + + for (i=1; i