@@ -3740,77 +3740,183 @@ namespace Plugin {
3740
3740
}
3741
3741
}
3742
3742
3743
- uint32_t AVOutputTV::resetPictureMode (const JsonObject& parameters, JsonObject& response )
3743
+ bool AVOutputTV::resetPictureModeV2 (const JsonObject& parameters)
3744
3744
{
3745
3745
LOGINFO (" Entry\n " );
3746
+
3746
3747
tr181ErrorCode_t err = tr181Success;
3747
3748
TR181_ParamData_t param = {0 };
3748
3749
3749
- valueVectors_t values;
3750
- capDetails_t inputInfo;
3751
-
3752
- // As only source need to validate, so pqmode and formate passing as currrent
3753
- if (parsingSetInputArgument (parameters, " PictureMode" ,inputInfo) != 0 ) {
3754
- LOGERR (" %s: Failed to parse the input arguments \n " , __FUNCTION__);
3755
- returnResponse (false );
3750
+ // Initialize videoSource and videoFormat arrays with "Current" if not provided
3751
+ std::vector<std::string> sourceArray;
3752
+ if (parameters.HasLabel (" videoSource" )) {
3753
+ const JsonArray& sourceParam = parameters[" videoSource" ].Array ();
3754
+ for (uint32_t i = 0 ; i < sourceParam.Length (); ++i) {
3755
+ sourceArray.push_back (sourceParam[i].Value ());
3756
+ }
3757
+ } else {
3758
+ sourceArray.push_back (" Current" );
3756
3759
}
3757
3760
3758
- if ( !isCapablityCheckPassed ( " PictureMode" ,inputInfo )) {
3759
- LOGERR (" %s: CapablityCheck failed for PictureMode\n " , __FUNCTION__);
3760
- returnResponse (false );
3761
+ std::vector<std::string> formatArray;
3762
+ if (parameters.HasLabel (" videoFormat" )) {
3763
+ const JsonArray& formatParam = parameters[" videoFormat" ].Array ();
3764
+ for (uint32_t i = 0 ; i < formatParam.Length (); ++i) {
3765
+ formatArray.push_back (formatParam[i].Value ());
3766
+ }
3767
+ } else {
3768
+ formatArray.push_back (" Current" );
3761
3769
}
3762
- inputInfo.pqmode = " Current" ;
3763
- getSaveConfig (" PictureMode" , inputInfo, values);
3764
3770
3765
- for (int source : values.sourceValues ) {
3766
- tvVideoSrcType_t sourceType = (tvVideoSrcType_t)source;
3767
- for (int format : values.formatValues ) {
3768
- tvVideoFormatType_t formatType = (tvVideoFormatType_t)format;
3769
- std::string tr181_param_name = " " ;
3770
- tr181_param_name += std::string (AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM);
3771
- tr181_param_name += " ." +convertSourceIndexToString (sourceType)+" ." +" Format." +
3772
- convertVideoFormatToString (formatType)+" ." +" PictureModeString" ;
3771
+ bool contextHandled = false ;
3773
3772
3774
- err = clearLocalParam (rfc_caller_id, tr181_param_name.c_str ());
3775
- if ( err != tr181Success ) {
3776
- LOGWARN (" clearLocalParam for %s Failed : %s\n " , tr181_param_name.c_str (), getTR181ErrorString (err));
3777
- returnResponse (false );
3773
+ // Loop through all the contexts in m_pictureModeCaps
3774
+ for (size_t i = 0 ; i < m_pictureModeCaps->num_contexts ; ++i) {
3775
+ const tvConfigContext_t& ctx = m_pictureModeCaps->contexts [i];
3776
+
3777
+ // Check if the current context matches the requested videoSource
3778
+ if (!isValidSource (sourceArray, ctx.videoSrcType )) {
3779
+ continue ; // Skip if the source doesn't match
3780
+ }
3781
+
3782
+ // Check if the current context matches the requested videoFormat
3783
+ if (!isValidFormat (formatArray, ctx.videoFormatType )) {
3784
+ continue ; // Skip if the format doesn't match
3785
+ }
3786
+
3787
+ std::string tr181_param_name = AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM;
3788
+ tr181_param_name += " ." + convertSourceIndexToString (ctx.videoSrcType );
3789
+ tr181_param_name += " .Format." + convertVideoFormatToString (ctx.videoFormatType );
3790
+ tr181_param_name += " .PictureModeString" ;
3791
+
3792
+ err = clearLocalParam (rfc_caller_id, tr181_param_name.c_str ());
3793
+ if (err != tr181Success) {
3794
+ LOGWARN (" clearLocalParam failed for %s: %s\n " , tr181_param_name.c_str (), getTR181ErrorString (err));
3795
+ continue ;
3796
+ }
3797
+
3798
+ err = getLocalParam (rfc_caller_id, tr181_param_name.c_str (), ¶m);
3799
+ if (err != tr181Success) {
3800
+ #if DEBUG
3801
+ LOGWARN (" getLocalParam failed for %s\n " , tr181_param_name.c_str ());
3802
+ #endif
3803
+ continue ;
3804
+ }
3805
+
3806
+ // Get the current video source and format
3807
+ tvVideoSrcType_t current_source = VIDEO_SOURCE_IP;
3808
+ tvVideoFormatType_t current_format = VIDEO_FORMAT_NONE;
3809
+ GetCurrentVideoSource (¤t_source);
3810
+ GetCurrentVideoFormat (¤t_format);
3811
+ if (current_format == VIDEO_FORMAT_NONE)
3812
+ current_format = VIDEO_FORMAT_SDR;
3813
+
3814
+ // If current source and format match the context, apply the picture mode
3815
+ if (current_source == ctx.videoSrcType && current_format == ctx.videoFormatType ) {
3816
+ tvError_t ret = SetTVPictureMode (param.value );
3817
+ if (ret != tvERROR_NONE) {
3818
+ LOGWARN (" SetTVPictureMode failed: %s\n " , getErrorString (ret).c_str ());
3819
+ continue ;
3820
+ } else {
3821
+ LOGINFO (" PictureMode applied to current context: %s\n " , param.value );
3778
3822
}
3779
- else {
3780
- err = getLocalParam (rfc_caller_id, tr181_param_name.c_str (), ¶m);
3781
- if ( tr181Success == err ) {
3782
- // get curren source and if matches save for that alone
3783
- tvVideoSrcType_t current_source = VIDEO_SOURCE_IP;
3784
- GetCurrentVideoSource (¤t_source);
3785
-
3786
- tvVideoFormatType_t current_format = VIDEO_FORMAT_NONE;
3787
- GetCurrentVideoFormat (¤t_format);
3788
- if ( current_format == VIDEO_FORMAT_NONE) {
3789
- current_format = VIDEO_FORMAT_SDR;
3790
- }
3823
+ }
3824
+
3825
+ int pqmodeindex = getPictureModeIndex (param.value );
3826
+ SaveSourcePictureMode (ctx.videoSrcType , ctx.videoFormatType , pqmodeindex);
3827
+ contextHandled = true ;
3828
+ }
3829
+
3830
+
3831
+ if (!contextHandled) {
3832
+ LOGWARN (" No applicable contexts handled for PictureMode reset\n " );
3833
+ return false ;
3834
+ }
3835
+
3836
+ LOGINFO (" Exit: PictureMode reset completed for all matching contexts.\n " );
3837
+ return true ;
3838
+ }
3791
3839
3792
- if (current_source == sourceType && current_format == formatType) {
3793
- LOGINFO (" PQ mode =%s\n " ,param.value );
3794
- tvError_t ret = tvERROR_NONE;
3795
- if (ret != tvERROR_NONE) {
3796
- LOGWARN (" Picture Mode set failed: %s\n " ,getErrorString (ret).c_str ());
3797
- returnResponse (false );
3840
+ uint32_t AVOutputTV::resetPictureMode (const JsonObject& parameters, JsonObject& response)
3841
+ {
3842
+ LOGINFO (" Entry\n " );
3843
+ if (m_pictureModeStatus == tvERROR_OPERATION_NOT_SUPPORTED)
3844
+ {
3845
+ tr181ErrorCode_t err = tr181Success;
3846
+ TR181_ParamData_t param = {0 };
3847
+
3848
+ valueVectors_t values;
3849
+ capDetails_t inputInfo;
3850
+
3851
+ // As only source need to validate, so pqmode and formate passing as currrent
3852
+ if (parsingSetInputArgument (parameters, " PictureMode" ,inputInfo) != 0 ) {
3853
+ LOGERR (" %s: Failed to parse the input arguments \n " , __FUNCTION__);
3854
+ returnResponse (false );
3855
+ }
3856
+
3857
+ if ( !isCapablityCheckPassed ( " PictureMode" ,inputInfo )) {
3858
+ LOGERR (" %s: CapablityCheck failed for PictureMode\n " , __FUNCTION__);
3859
+ returnResponse (false );
3860
+ }
3861
+ inputInfo.pqmode = " Current" ;
3862
+ getSaveConfig (" PictureMode" , inputInfo, values);
3863
+
3864
+ for (int source : values.sourceValues ) {
3865
+ tvVideoSrcType_t sourceType = (tvVideoSrcType_t)source;
3866
+ for (int format : values.formatValues ) {
3867
+ tvVideoFormatType_t formatType = (tvVideoFormatType_t)format;
3868
+ std::string tr181_param_name = " " ;
3869
+ tr181_param_name += std::string (AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM);
3870
+ tr181_param_name += " ." +convertSourceIndexToString (sourceType)+" ." +" Format." +
3871
+ convertVideoFormatToString (formatType)+" ." +" PictureModeString" ;
3872
+
3873
+ err = clearLocalParam (rfc_caller_id, tr181_param_name.c_str ());
3874
+ if ( err != tr181Success ) {
3875
+ LOGWARN (" clearLocalParam for %s Failed : %s\n " , tr181_param_name.c_str (), getTR181ErrorString (err));
3876
+ returnResponse (false );
3877
+ >>>>>>> d9c44794 (Implement context based resetPictureMode)
3878
+ }
3879
+ else {
3880
+ err = getLocalParam (rfc_caller_id, tr181_param_name.c_str (), ¶m);
3881
+ if ( tr181Success == err ) {
3882
+ // get curren source and if matches save for that alone
3883
+ tvVideoSrcType_t current_source = VIDEO_SOURCE_IP;
3884
+ GetCurrentVideoSource (¤t_source);
3885
+
3886
+ tvVideoFormatType_t current_format = VIDEO_FORMAT_NONE;
3887
+ GetCurrentVideoFormat (¤t_format);
3888
+ if ( current_format == VIDEO_FORMAT_NONE) {
3889
+ current_format = VIDEO_FORMAT_SDR;
3798
3890
}
3799
- else {
3800
- LOGINFO (" Exit : Picture Mode reset successfully, value: %s\n " , param.value );
3891
+
3892
+ if (current_source == sourceType && current_format == formatType) {
3893
+
3894
+ tvError_t ret = SetTVPictureMode (param.value );
3895
+ if (ret != tvERROR_NONE) {
3896
+ LOGWARN (" Picture Mode set failed: %s\n " ,getErrorString (ret).c_str ());
3897
+ returnResponse (false );
3898
+ }
3899
+ else {
3900
+ LOGINFO (" Exit : Picture Mode reset successfully, value: %s\n " , param.value );
3901
+ }
3801
3902
}
3903
+ int pqmodeindex = (int )getPictureModeIndex (param.value );
3904
+ SaveSourcePictureMode (sourceType, formatType, pqmodeindex);
3905
+ }
3906
+ else {
3907
+ LOGWARN (" getLocalParam for %s failed\n " , AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM);
3908
+ returnResponse (false );
3802
3909
}
3803
- int pqmodeindex = (int )getPictureModeIndex (param.value );
3804
- SaveSourcePictureMode (sourceType, formatType, pqmodeindex);
3805
- }
3806
- else {
3807
- LOGWARN (" getLocalParam for %s failed\n " , AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM);
3808
- returnResponse (false );
3809
3910
}
3810
3911
}
3811
3912
}
3913
+ returnResponse (true );
3914
+ }
3915
+ else
3916
+ {
3917
+ bool success = resetPictureModeV2 (parameters);
3918
+ returnResponse (success);
3812
3919
}
3813
- returnResponse (true )
3814
3920
}
3815
3921
3816
3922
uint32_t AVOutputTV::signalFilmMakerMode (const JsonObject& parameters, JsonObject& response)
0 commit comments