⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upnp_tv_device.c

📁 Upnp开发包文件
💻 C
📖 第 1 页 / 共 5 页
字号:
    if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL,                                    TV_CONTROL_CHANNEL, value ) ) {        if( UpnpAddToActionResponse( out, "SetChannel",                                     TvServiceType[TV_SERVICE_CONTROL],                                     "NewChannel",                                     value ) != UPNP_E_SUCCESS ) {            ( *out ) = NULL;            ( *errorString ) = "Internal Error";            free( value );            return UPNP_E_INTERNAL_ERROR;        }        free( value );        return UPNP_E_SUCCESS;    } else {        free( value );        ( *errorString ) = "Internal Error";        return UPNP_E_INTERNAL_ERROR;    }}/****************************************************************************** * IncrementChannel * * Description:  *       Increment the channel.  Read the current channel from the state *       table, add the increment, and then change the channel. * * Parameters: *   incr -- The increment by which to change the channel. *       *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intIncrementChannel( IN int incr,                  IN IXML_Document * in,                  OUT IXML_Document ** out,                  OUT char **errorString ){    int curchannel,      newchannel;    char *actionName = NULL;    char value[TV_MAX_VAL_LEN];    if( incr > 0 ) {        actionName = "IncreaseChannel";    } else {        actionName = "DecreaseChannel";    }    ithread_mutex_lock( &TVDevMutex );    curchannel = atoi( tv_service_table[TV_SERVICE_CONTROL].                       VariableStrVal[TV_CONTROL_CHANNEL] );    ithread_mutex_unlock( &TVDevMutex );    newchannel = curchannel + incr;    if( newchannel < MIN_CHANNEL || newchannel > MAX_CHANNEL ) {        SampleUtil_Print( "error: can't change to channel %d\n",                          newchannel );        ( *errorString ) = "Invalid Channel";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the channel goes here      */    sprintf( value, "%d", newchannel );    if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL,                                    TV_CONTROL_CHANNEL, value ) ) {        if( UpnpAddToActionResponse( out, actionName,                                     TvServiceType[TV_SERVICE_CONTROL],                                     "Channel", value ) != UPNP_E_SUCCESS )        {            ( *out ) = NULL;            ( *errorString ) = "Internal Error";            return UPNP_E_INTERNAL_ERROR;        }        return UPNP_E_SUCCESS;    } else {        ( *errorString ) = "Internal Error";        return UPNP_E_INTERNAL_ERROR;    }}/****************************************************************************** * TvDeviceDecreaseChannel * * Description:  *       Decrease the channel.   * * Parameters: *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceDecreaseChannel( IN IXML_Document * in,                         OUT IXML_Document ** out,                         OUT char **errorString ){    return IncrementChannel( -1, in, out, errorString );}/****************************************************************************** * TvDeviceIncreaseChannel * * Description:  *       Increase the channel.   * * Parameters: *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceIncreaseChannel( IN IXML_Document * in,                         OUT IXML_Document ** out,                         OUT char **errorString ){    return IncrementChannel( 1, in, out, errorString );}/****************************************************************************** * TvDeviceSetVolume * * Description:  *       Change the volume, update the TvDevice control service *       state table, and notify all subscribed control points of the *       updated state. * * Parameters: *   *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceSetVolume( IN IXML_Document * in,                   OUT IXML_Document ** out,                   OUT char **errorString ){    char *value = NULL;    int volume = 0;    ( *out ) = NULL;    ( *errorString ) = NULL;    if( !( value = SampleUtil_GetFirstDocumentItem( in, "Volume" ) ) ) {        ( *errorString ) = "Invalid Volume";        return UPNP_E_INVALID_PARAM;    }    volume = atoi( value );    if( volume < MIN_VOLUME || volume > MAX_VOLUME ) {        SampleUtil_Print( "error: can't change to volume %d\n", volume );        ( *errorString ) = "Invalid Volume";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the volume goes here      */    if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL,                                    TV_CONTROL_VOLUME, value ) ) {        if( UpnpAddToActionResponse( out, "SetVolume",                                     TvServiceType[TV_SERVICE_CONTROL],                                     "NewVolume",                                     value ) != UPNP_E_SUCCESS ) {            ( *out ) = NULL;            ( *errorString ) = "Internal Error";            free( value );            return UPNP_E_INTERNAL_ERROR;        }        free( value );        return UPNP_E_SUCCESS;    } else {        free( value );        ( *errorString ) = "Internal Error";        return UPNP_E_INTERNAL_ERROR;    }}/****************************************************************************** * IncrementVolume * * Description:  *       Increment the volume.  Read the current volume from the state *       table, add the increment, and then change the volume. * * Parameters: *   incr -- The increment by which to change the volume. *       *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intIncrementVolume( IN int incr,                 IN IXML_Document * in,                 OUT IXML_Document ** out,                 OUT char **errorString ){    int curvolume,      newvolume;    char *actionName = NULL;    char value[TV_MAX_VAL_LEN];    if( incr > 0 ) {        actionName = "IncreaseVolume";    } else {        actionName = "DecreaseVolume";    }    ithread_mutex_lock( &TVDevMutex );    curvolume = atoi( tv_service_table[TV_SERVICE_CONTROL].                      VariableStrVal[TV_CONTROL_VOLUME] );    ithread_mutex_unlock( &TVDevMutex );    newvolume = curvolume + incr;    if( newvolume < MIN_VOLUME || newvolume > MAX_VOLUME ) {        SampleUtil_Print( "error: can't change to volume %d\n",                          newvolume );        ( *errorString ) = "Invalid Volume";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the channel goes here      */    sprintf( value, "%d", newvolume );    if( TvDeviceSetServiceTableVar( TV_SERVICE_CONTROL,                                    TV_CONTROL_VOLUME, value ) ) {        if( UpnpAddToActionResponse( out, actionName,                                     TvServiceType[TV_SERVICE_CONTROL],                                     "Volume", value ) != UPNP_E_SUCCESS )        {            ( *out ) = NULL;            ( *errorString ) = "Internal Error";            return UPNP_E_INTERNAL_ERROR;        }        return UPNP_E_SUCCESS;    } else {        ( *errorString ) = "Internal Error";        return UPNP_E_INTERNAL_ERROR;    }}/****************************************************************************** * TvDeviceIncrVolume * * Description:  *       Increase the volume.  * * Parameters: *    * *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intTvDeviceIncreaseVolume( IN IXML_Document * in,                        OUT IXML_Document ** out,                        OUT char **errorString ){    return IncrementVolume( 1, in, out, errorString );}/****************************************************************************** * TvDeviceDecreaseVolume * * Description:  *       Decrease the volume. * * Parameters: *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceDecreaseVolume( IN IXML_Document * in,                        OUT IXML_Document ** out,                        OUT char **errorString ){    return IncrementVolume( -1, in, out, errorString );}/****************************************************************************** * TvDeviceSetColor * * Description:  *       Change the color, update the TvDevice picture service *       state table, and notify all subscribed control points of the *       updated state. * * Parameters: *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceSetColor( IN IXML_Document * in,                  OUT IXML_Document ** out,                  OUT char **errorString ){    char *value = NULL;    int color = 0;    ( *out ) = NULL;    ( *errorString ) = NULL;    if( !( value = SampleUtil_GetFirstDocumentItem( in, "Color" ) ) ) {        ( *errorString ) = "Invalid Color";        return UPNP_E_INVALID_PARAM;    }    color = atoi( value );    if( color < MIN_COLOR || color > MAX_COLOR ) {        SampleUtil_Print( "error: can't change to color %d\n", color );        ( *errorString ) = "Invalid Color";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the volume goes here      */    if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE,                                    TV_PICTURE_COLOR, value ) ) {        if( UpnpAddToActionResponse( out, "SetColor",                                     TvServiceType[TV_SERVICE_PICTURE],                                     "NewColor",                                     value ) != UPNP_E_SUCCESS ) {            ( *out ) = NULL;            ( *errorString ) = "Internal Error";            free( value );            return UPNP_E_INTERNAL_ERROR;        }        free( value );        return UPNP_E_SUCCESS;    } else {        free( value );        ( *errorString ) = "Internal Error";        return UPNP_E_INTERNAL_ERROR;    }}/****************************************************************************** * IncrementColor * * Description:  *       Increment the color.  Read the current color from the state *       table, add the increment, and then change the color. * * Parameters: *   incr -- The increment by which to change the color. *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intIncrementColor( IN int incr,                IN IXML_Document * in,                OUT IXML_Document ** out,                OUT char **errorString ){    int curcolor,      newcolor;    char *actionName;    char value[TV_MAX_VAL_LEN];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -