Exemplo n.º 1
0
Bool16 PLBroadcastDef::ConfigSetter( const char* paramName, const char* paramValue[], void* userData )
{
    // return true if set fails
    
    
    PLBroadcastDef* broadcastParms = (PLBroadcastDef*)userData;
    
    if (!::strcmp( "destination_ip_address", paramName) )
    {   
        broadcastParms->SetValue( &broadcastParms->mOrigDestAddress, paramValue[0] );
        if (broadcastParms->mIgnoreFileIP)
            return false;
        else
            return broadcastParms->SetValue( &broadcastParms->mDestAddress, paramValue[0] );
    }
    else if (!::strcmp( "destination_base_port", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mBasePort, paramValue[0] );

    }
    else if (!::strcmp( "max_upcoming_list_size", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mMaxUpcomingMovieListSize, paramValue[0] );

    }
    else if (!::strcmp( "play_mode", paramName) )
    {
            
        if ( ::strcmp( "sequential", paramValue[0]) 
            && ::strcmp( "sequential_looped", paramValue[0])
            && ::strcmp( "weighted_random", paramValue[0])
            )
            return true;

        return broadcastParms->SetValue( &broadcastParms->mPlayMode, paramValue[0] );

    }   
    /*
    rt- rremoved for buld 12
    else if (!::strcmp( "limit_play", paramName) )
    {
        if ( ::strcmp( "enabled", paramValue[0]) && ::strcmp( "disabled", paramValue[0]) )
            return true;

        return broadcastParms->SetValue( &broadcastParms->mLimitPlay, paramValue[0] );

    }
    */
    // changed at bulid 12 else if (!::strcmp( "repeats_queue_size", paramName) )
    else if (!::strcmp( "recent_movies_list_size", paramName) )
    {
        if ( ::atoi( paramValue[0] )  < 0 )
            return true;
            
        broadcastParms->mLimitPlayQueueLength = atoi(paramValue[0]);

        return false;
        
    }
    else if (!::strcmp( "playlist_file", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mPlayListFile, paramValue[0] );

    }
    else if (!::strcmp( "sdp_file", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mSDPFile, paramValue[0] );

    }
    else if (!::strcmp( "destination_sdp_file", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mDestSDPFile, paramValue[0] );

    }
    else if (!::strcmp( "logging", paramName) )
    {
        if ( ::strcmp( "enabled", paramValue[0]) && ::strcmp( "disabled", paramValue[0]) )
            return true;

        return broadcastParms->SetValue( &broadcastParms->mLogging, paramValue[0] );

    }
    else if (!::strcmp( "log_file", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mLogFile, paramValue[0] );

    }
    else if (!::strcmp( "sdp_reference_movie", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mSDPReferenceMovie, paramValue[0] );

    }
    else if (!::strcmp( "show_current", paramName) )
    {
        if ( ::strcmp( "enabled", paramValue[0]) && ::strcmp( "disabled", paramValue[0]) )
            return true;
            
        return broadcastParms->SetValue( &broadcastParms->mShowCurrent, paramValue[0] );

    }
    else if (!::strcmp( "show_upcoming", paramName) )
    {
        if ( ::strcmp( "enabled", paramValue[0]) && ::strcmp( "disabled", paramValue[0]) )
            return true;
            
        return broadcastParms->SetValue( &broadcastParms->mShowUpcoming, paramValue[0] );

    }
	else if (!::strcmp( "broadcast_start_time", paramName) )
	{
	    
        const char* theValue = paramValue[0];
        if ('*' == theValue[0])
	    {    
	        UInt32 startTime =  time(NULL) + 2208988800LU + (time_t) ::strtol(&theValue[1], NULL, 10);
	        char startTimeStr[20] = "";
	        qtss_sprintf(startTimeStr,"%lu", startTime); // current time
		    return broadcastParms->SetValue( &broadcastParms->mStartTime, startTimeStr );            
        }
          
		return broadcastParms->SetValue( &broadcastParms->mStartTime, paramValue[0] );
	}
    else if (!::strcmp( "broadcast_end_time", paramName) )
    {
        UInt32 endTime = 0;
        const char* theValue = paramValue[0];
        if ('*' == theValue[0])
            endTime =  time(NULL) + 2208988800LU + (SInt32) ::strtol(&theValue[1], NULL, 10);
        else 
            endTime = ::strtoul(theValue, NULL, 10);

        if ( (endTime > 0) && endTime <  2208988800LU) // not a valid time
            return true;
                
        char endTimeStr[20] = "";
        qtss_sprintf(endTimeStr,"%lu", endTime); // current time + offset time
        return broadcastParms->SetValue( &broadcastParms->mEndTime, endTimeStr ); 
             
    }
    else if (!::strcmp( "broadcast_SDP_is_dynamic", paramName) )
    {
        if ( ::strcmp( "enabled", paramValue[0]) && ::strcmp( "disabled", paramValue[0]) )
            return true;
            
        return broadcastParms->SetValue( &broadcastParms->mIsDynamic, paramValue[0] );
    }
    else if (!::strcmp( "broadcaster_name", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mName, paramValue[0] );

    }
    else if (!::strcmp( "broadcaster_password", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mPassword, paramValue[0] );

    }
    else if (!::strcmp( "multicast_ttl", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mTTL, paramValue[0] );

    }
    else if (!::strcmp( "rtsp_port", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mRTSPPort, paramValue[0] );

    }
    else if (!::strcmp( "pid_file", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mPIDFile, paramValue[0] );

    }
    else if (!::strcmp( "client_buffer_delay", paramName) )
    {
        return broadcastParms->SetValue( &broadcastParms->mClientBufferDelay, paramValue[0] );

    }
    else if (!::strcmp( "max_err_file_k_size", paramName) )
    {
		if ( !paramValue[0] || !strlen(paramValue[0]) )
			return true;

  		unsigned long setvalue = kSInt32_Max;
		int maxValue = ::atoi( paramValue[0] );
  		if (maxValue >= 0)
			setvalue = (unsigned long) maxValue;
		
		qtss_setmaxprintfcharsinK( (unsigned long) setvalue);
        return false;
    }

    
    return true;
}
Bool16 MP3Broadcaster::ConfigSetter( const char* paramName, const char* paramValue[], void* userData )
{
    // return true if set fails
    MP3Broadcaster* thisPtr = (MP3Broadcaster*)userData;

    if (!::strcmp( "destination_ip_address", paramName) )
    {   
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mIPAddr))
            return true;
        
        strcpy(thisPtr->mIPAddr, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "destination_base_port", paramName) )
    {
        thisPtr->mPort = atoi(paramValue[0]);

        return false;
    }
    else if (!::strcmp( "max_upcoming_list_size", paramName) )
    {
        if ( ::atoi( paramValue[0] )  < 0 )
            return true;
            
        thisPtr->mUpcomingSongsListSize = ::atoi( paramValue[0] );
        return false;
    }
    else if (!::strcmp( "play_mode", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mPlayMode))
            return true;
        
        strcpy(thisPtr->mPlayMode, paramValue[0]);
        return false;
    }   
    else if (!::strcmp( "recent_songs_list_size", paramName) )
    {
        if ( ::atoi( paramValue[0] )  < 0 )
            return true;
            
        thisPtr->mRecentSongsListSize = ::atoi( paramValue[0] );
        return false;
    }
    else if (!::strcmp( "playlist_file", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mPlayListPath))
            return true;
        
        strcpy(thisPtr->mPlayListPath, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "working_dir", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mWorkingDirPath))
            return true;
        
        strcpy(thisPtr->mWorkingDirPath, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "logging", paramName) )
    {
        return SetEnabled(paramValue[0], &thisPtr->mLogging);
    }
    else if (!::strcmp( "show_current", paramName) )
    {
        return SetEnabled(paramValue[0], &thisPtr->mShowCurrent);
    }
    else if (!::strcmp( "show_upcoming", paramName) )
    {
        return SetEnabled(paramValue[0], &thisPtr->mShowUpcoming);
    }
    else if (!::strcmp( "use_icy", paramName) )
    {
        return SetEnabled(paramValue[0], &thisPtr->mUseICY);
    }
    else if (!::strcmp( "broadcast_name", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mName))
            return true;
        
        strcpy(thisPtr->mName, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "broadcast_password", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mPassword))
            return true;
        
        strcpy(thisPtr->mPassword, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "broadcast_genre", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mGenre))
            return true;
        
        strcpy(thisPtr->mGenre, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "broadcast_url", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mURL))
            return true;
        
        strcpy(thisPtr->mURL, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "broadcast_bitrate", paramName) )
    {
        if ( ::atoi( paramValue[0] )  < 0 )
            return true;
            
        thisPtr->mBitRate = ::atoi( paramValue[0] );
        return false;
    }
    else if (!::strcmp( "broadcast_sample_rate", paramName) )
    {
        if ( ::atoi( paramValue[0] )  < -1 )
            return true;
            
        thisPtr->mFrequency = ::atoi( paramValue[0] );
        return false;
    }
    else if (!::strcmp( "broadcast_mount_point", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mMountPoint))
            return true;
        // Make sure the mountpoint always begins with a '/' character.
        // If its missing prepend it to the mountpoint name for them.
        thisPtr->mMountPoint[0] = '\0';
        if (*paramValue[0] != '/')
            strcpy(thisPtr->mMountPoint, "/");
        strcat(thisPtr->mMountPoint, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "pid_file", paramName) )
    {
        if (strlen(paramValue[0]) >= sizeof(thisPtr->mPIDFile))
            return true;
        
        strcpy(thisPtr->mPIDFile, paramValue[0]);
        return false;
    }
    else if (!::strcmp( "max_err_file_k_size", paramName) )
    {
        if ( !paramValue[0] || !::strlen(paramValue[0]) )
             return true;
			
        UInt32 setvalue = kSInt32_Max;
        int maxValue = ::atoi( paramValue[0] );
        if (maxValue >= 0)
            setvalue = (UInt32) maxValue;
		
        qtss_setmaxprintfcharsinK( (UInt32) setvalue);
        return false;
    }
    
    return true;
}