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

📄 upnp_tv_device.c

📁 Upnp开发包文件
💻 C
📖 第 1 页 / 共 5 页
字号:
    if( incr > 0 ) {        actionName = "IncreaseColor";    } else {        actionName = "DecreaseColor";    }    ithread_mutex_lock( &TVDevMutex );    curcolor = atoi( tv_service_table[TV_SERVICE_PICTURE].                     VariableStrVal[TV_PICTURE_COLOR] );    ithread_mutex_unlock( &TVDevMutex );    newcolor = curcolor + incr;    if( newcolor < MIN_COLOR || newcolor > MAX_COLOR ) {        SampleUtil_Print( "error: can't change to color %d\n", newcolor );        ( *errorString ) = "Invalid Color";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the channel goes here      */    sprintf( value, "%d", newcolor );    if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE,                                    TV_PICTURE_COLOR, value ) ) {        if( UpnpAddToActionResponse( out, actionName,                                     TvServiceType[TV_SERVICE_PICTURE],                                     "Color", 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;    }}/****************************************************************************** * TvDeviceDecreaseColor * * Description:  *       Decrease the color.   * * Parameters: *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intTvDeviceDecreaseColor( IN IXML_Document * in,                       OUT IXML_Document ** out,                       OUT char **errorString ){    return IncrementColor( -1, in, out, errorString );}/****************************************************************************** * TvDeviceIncreaseColor * * Description:  *       Increase the color. * * Parameters: * *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intTvDeviceIncreaseColor( IN IXML_Document * in,                       OUT IXML_Document ** out,                       OUT char **errorString ){    return IncrementColor( 1, in, out, errorString );}/****************************************************************************** * TvDeviceSetTint * * Description:  *       Change the tint, 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) * *****************************************************************************/intTvDeviceSetTint( IN IXML_Document * in,                 OUT IXML_Document ** out,                 OUT char **errorString ){    char *value = NULL;    int tint = -1;    ( *out ) = NULL;    ( *errorString ) = NULL;    if( !( value = SampleUtil_GetFirstDocumentItem( in, "Tint" ) ) ) {        ( *errorString ) = "Invalid Tint";        return UPNP_E_INVALID_PARAM;    }    tint = atoi( value );    if( tint < MIN_TINT || tint > MAX_TINT ) {        SampleUtil_Print( "error: can't change to tint %d\n", tint );        ( *errorString ) = "Invalid Tint";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the volume goes here      */    if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE,                                    TV_PICTURE_TINT, value ) ) {        if( UpnpAddToActionResponse( out, "SetTint",                                     TvServiceType[TV_SERVICE_PICTURE],                                     "NewTint", 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;    }}/****************************************************************************** * IncrementTint * * Description:  *       Increment the tint.  Read the current tint from the state *       table, add the increment, and then change the tint. * * Parameters: *   incr -- The increment by which to change the tint. *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intIncrementTint( IN int incr,               IN IXML_Document * in,               OUT IXML_Document ** out,               OUT char **errorString ){    int curtint,      newtint;    char *actionName = NULL;    char value[TV_MAX_VAL_LEN];    if( incr > 0 ) {        actionName = "IncreaseTint";    } else {        actionName = "DecreaseTint";    }    ithread_mutex_lock( &TVDevMutex );    curtint = atoi( tv_service_table[TV_SERVICE_PICTURE].                    VariableStrVal[TV_PICTURE_TINT] );    ithread_mutex_unlock( &TVDevMutex );    newtint = curtint + incr;    if( newtint < MIN_TINT || newtint > MAX_TINT ) {        SampleUtil_Print( "error: can't change to tint %d\n", newtint );        ( *errorString ) = "Invalid Tint";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the channel goes here      */    sprintf( value, "%d", newtint );    if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE,                                    TV_PICTURE_TINT, value ) ) {        if( UpnpAddToActionResponse( out, actionName,                                     TvServiceType[TV_SERVICE_PICTURE],                                     "Tint", 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;    }}/****************************************************************************** * TvDeviceIncreaseTint * * Description:  *       Increase tint. * * Parameters: *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceIncreaseTint( IN IXML_Document * in,                      OUT IXML_Document ** out,                      OUT char **errorString ){    return IncrementTint( 1, in, out, errorString );}/****************************************************************************** * TvDeviceDecreaseTint * * Description:  *       Decrease tint. * * Parameters: *   *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) * *****************************************************************************/intTvDeviceDecreaseTint( IN IXML_Document * in,                      OUT IXML_Document ** out,                      OUT char **errorString ){    return IncrementTint( -1, in, out, errorString );}/***************************************************************************** * TvDeviceSetContrast * * Description:  *       Change the contrast, 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) * ****************************************************************************/intTvDeviceSetContrast( IN IXML_Document * in,                     OUT IXML_Document ** out,                     OUT char **errorString ){    char *value = NULL;    int contrast = -1;    ( *out ) = NULL;    ( *errorString ) = NULL;    if( !( value = SampleUtil_GetFirstDocumentItem( in, "Contrast" ) ) ) {        ( *errorString ) = "Invalid Contrast";        return UPNP_E_INVALID_PARAM;    }    contrast = atoi( value );    if( contrast < MIN_CONTRAST || contrast > MAX_CONTRAST ) {        SampleUtil_Print( "error: can't change to contrast %d\n",                          contrast );        ( *errorString ) = "Invalid Contrast";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the volume goes here      */    if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE,                                    TV_PICTURE_CONTRAST, value ) ) {        if( UpnpAddToActionResponse( out, "SetContrast",                                     TvServiceType[TV_SERVICE_PICTURE],                                     "NewContrast",                                     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;    }}/****************************************************************************** * IncrementContrast * * Description:  *       Increment the contrast.  Read the current contrast from the state *       table, add the increment, and then change the contrast. * * Parameters: *   incr -- The increment by which to change the contrast. *    *    IXML_Document * in -  action request document *    IXML_Document **out - action result document *    char **errorString - errorString (in case action was unsuccessful) *****************************************************************************/intIncrementContrast( IN int incr,                   IN IXML_Document * in,                   OUT IXML_Document ** out,                   OUT char **errorString ){    int curcontrast,      newcontrast;    char *actionName = NULL;    char value[TV_MAX_VAL_LEN];    if( incr > 0 ) {        actionName = "IncreaseContrast";    } else {        actionName = "DecreaseContrast";    }    ithread_mutex_lock( &TVDevMutex );    curcontrast = atoi( tv_service_table[TV_SERVICE_PICTURE].                        VariableStrVal[TV_PICTURE_CONTRAST] );    ithread_mutex_unlock( &TVDevMutex );    newcontrast = curcontrast + incr;    if( newcontrast < MIN_CONTRAST || newcontrast > MAX_CONTRAST ) {        SampleUtil_Print( "error: can't change to contrast %d\n",                          newcontrast );        ( *errorString ) = "Invalid Contrast";        return UPNP_E_INVALID_PARAM;    }    /*       Vendor-specific code to set the channel goes here      */    sprintf( value, "%d", newcontrast );    if( TvDeviceSetServiceTableVar( TV_SERVICE_PICTURE,                                    TV_PICTURE_CONTRAST, value ) ) {        if( UpnpAddToActionResponse( out, actionName,                                     TvServiceType[TV_SERVICE_PICTURE],                                     "Contrast",                                     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;    }}/****************************************************************************** * TvDeviceIncreaseContrast * * Description:  * *      Increase the contrast. * * Parameters: *        *    IXML_Document * in -  action request document

⌨️ 快捷键说明

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