예제 #1
0
파일: occinfo.cpp 프로젝트: dschmidt/mirall
void Owncloudclient::writeElement( QXmlStreamWriter &xml )
{
  xml.writeStartElement( "owncloudclient" );
  if ( !version().isEmpty() ) {
    xml.writeTextElement(  "version", version() );
  }
  if ( !versionstring().isEmpty() ) {
    xml.writeTextElement(  "versionstring", versionstring() );
  }
  if ( !web().isEmpty() ) {
    xml.writeTextElement(  "web", web() );
  }
  xml.writeEndElement();
}
예제 #2
0
//===================================================================
//
// server creation and destruction
//
server_t LIBCOD_CALL *server_spawn() {
    server_t *result = xmalloc( sizeof( server_t ) );
    
    strcpy( result->hostname, "localhost" );
    strcpy( result->rconpassword, "none" );
    
    result->port = 28960;
    result->pingdelay = 0;
    result->rcondelay = 500;
    result->lastrconcommand = 0;
    result->timeout = 3;
    result->version = UNKNOWN;
    result->versionstring = versionstring( UNKNOWN );

    result->players = xmalloc( sizeof( player_t ) );
    result->playercount = 0;
    
    result->cvartable = xmalloc( sizeof( cvar_t ) );
    result->cvartablelength = 0;
    
    result->sethost = server_sethostname;
    result->setrcon = server_setrconpassword;
    
    return result;
}
예제 #3
0
파일: mad.c 프로젝트: mvd7793/RED-SIREN
enum mad_flow read_header(void *data, struct mad_header const * header)
{
    char long_currenttime_str[14]; /* this *will* fill if you're using 100000+ minute mp3s */
    char long_remaintime_str[14];
    static int frames_played = 0;
    
    buffer *playbuf = (buffer *)data;
    mad_timer_t time_remaining;
    char *ao_time;

    if (stop_playing_file)
    {
        stop_playing_file = 0;
        status = MPG321_STOPPED;
        return MAD_FLOW_STOP;
    }
    
    if(options.opt & MPG321_REMOTE_PLAY)
    {
        enum mad_flow mf;

        /* We might have to stop if the user inputs something */
        if ((mf = remote_get_input_nowait(playbuf)))
            return mf;
    }

    /* Stop playing if -n is used, and we're at the frame specified. */
    if ((playbuf->max_frames != -1) && (frames_played++ > playbuf->max_frames))
    {
        frames_played = 0;
        status = MPG321_STOPPED;
	if(options.opt & MPG321_ENABLE_BUFFER) Decoded_Frames->done = 1;
	//fprintf(stderr,"Total D: %d\n",Decoded_Frames->total_decoded_frames);
        return MAD_FLOW_STOP;
    }

    current_frame++;

    mad_timer_add(&current_time, header->duration);

    if(options.opt & MPG321_USE_SCROBBLER && scrobbler_time > 0 && scrobbler_time < current_time.seconds)
    {
	    scrobbler_time = -1;
	    scrobbler_report();
    }

    if(options.opt & (MPG321_VERBOSE_PLAY | MPG321_REMOTE_PLAY))
    {
        mad_timer_string(current_time, long_currenttime_str, "%.2u:%.2u.%.2u", MAD_UNITS_MINUTES,
                            MAD_UNITS_CENTISECONDS, 0);

        if (mad_timer_compare(playbuf->duration, mad_timer_zero) == 0)
            time_remaining = current_time;
        else
            time_remaining = playbuf->duration;


        mad_timer_negate(&current_time);

        mad_timer_add(&time_remaining, current_time);
        mad_timer_negate(&current_time);

        mad_timer_string(time_remaining, long_remaintime_str, "%.2u:%.2u.%.2u", MAD_UNITS_MINUTES,
                            MAD_UNITS_CENTISECONDS, 0);
    }
                        
    /* update cached table of frames & times */
    if (current_frame <= playbuf->num_frames) /* we only allocate enough for our estimate. */
    {
        playbuf->frames[current_frame] = playbuf->frames[current_frame-1] + (header->bitrate / 8 / 1000)
            * mad_timer_count(header->duration, MAD_UNITS_MILLISECONDS);
        playbuf->times[current_frame] = current_time;
    }
    
    if (file_change)
    {
        file_change = 0;
        if (options.opt & MPG321_REMOTE_PLAY)
        {
            printf("@S %s %d %d %s %d %ld %d %d %d %d %ld %d\n",versionstring(header->flags), header->layer, header->samplerate,
                modestringucase(header->mode), header->mode_extension, 
                (header->bitrate / 8 / 100) * mad_timer_count(header->duration, MAD_UNITS_CENTISECONDS),
                MAD_NCHANNELS(header), header->flags & MAD_FLAG_COPYRIGHT ? 1 : 0, 
                header->flags & MAD_FLAG_PROTECTION ? 1 : 0, header->emphasis,
                header->bitrate/1000, header->mode_extension);
        }    

        else if (options.opt & MPG321_VERBOSE_PLAY)/*zip it good*/
        {
            fprintf(stderr, "MPEG %s, Layer: %s, Freq: %d, mode: %s, modext: %d, BPF : %ld\n"
                    "Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n"
                    "Bitrate: %ld Kbits/s, Extension value: %d\n"
                    "Audio: 1:1 conversion, rate: %d, encoding: signed 16 bit, channels: %d\n",
                    versionstring(header->flags),layerstring(header->layer), header->samplerate, modestringucase(header->mode), header->mode_extension, 
                    (header->bitrate / 100) * mad_timer_count(header->duration, MAD_UNITS_CENTISECONDS),
                    MAD_NCHANNELS(header), header->flags & MAD_FLAG_COPYRIGHT ? "Yes" : "No",
                    header->flags & MAD_FLAG_ORIGINAL ? "Yes" : "No", header->flags & MAD_FLAG_PROTECTION ? "Yes" : "No",
                    header->emphasis, header->bitrate/1000, header->mode_extension,
                    header->samplerate, MAD_NCHANNELS(header));
        }

        else if (!(options.opt & MPG321_QUIET_PLAY))/*I love Joey*/
        {
            fprintf(stderr, "MPEG %s layer %s, %ld kbit/s, %d Hz %s\n",
                versionstring(header->flags),layerstring(header->layer), header->bitrate/1000, header->samplerate, modestring(header->mode));
        }
    }
    
    if (status == MPG321_SEEKING && options.seek)
    {
        if (!--options.seek)
            status = MPG321_PLAYING;

        return MAD_FLOW_IGNORE;
    }
    else
    {
        status = MPG321_PLAYING;
    }

    if(!(options.opt & MPG321_ENABLE_BUFFER))
    {
	    if(count > 0)
	    {
		    count++;
		    if(count > 40)
		    {
			    if(!(options.opt & MPG321_VERBOSE_PLAY))
				    fprintf(stderr,"                \r");
			    count = -1;
			    fflush(stderr);
		    }
	    }
    }

    if(options.opt & MPG321_ENABLE_BUFFER)
    {
	    ao_time = (Output_Queue+mad_decoder_position)->time;
	    (Output_Queue+mad_decoder_position)->num_frames = playbuf->num_frames - current_frame;
	    if(Decoded_Frames->is_file) (Output_Queue+mad_decoder_position)->seconds = time_remaining.seconds;
    }

    if (options.opt & MPG321_VERBOSE_PLAY)
    {
        if (!options.skip_printing_frames 
            || (options.skip_printing_frames && !(current_frame % options.skip_printing_frames)))
   
	      	if(count > 0)
		{
/*			if(options.opt & MPG321_ENABLE_BUFFER)
			{	
				sprintf(ao_time, "Frame# %5lu [%5lu], Time: %s [%s], \r", current_frame,
					playbuf->num_frames > 0 ? playbuf->num_frames - current_frame : 0, long_currenttime_str, long_remaintime_str);
				//sprintf(ao_time, "Frame# %5lu [%5lu], Time: %s [%s], \r", current_frame,
				//	playbuf->num_frames > 0 ? playbuf->num_frames - current_frame : 0, long_currenttime_str, long_remaintime_str);
				//sprintf(ao_time, "Volume: %d%%  Frame# %5lu [%5lu], Time: %s [%s], \r",volume, current_frame,
				//	playbuf->num_frames > 0 ? playbuf->num_frames - current_frame : 0, long_currenttime_str, long_remaintime_str);
			}else*/
			{
				fprintf(stderr, "Volume: %d%%  Frame# %5lu [%5lu], Time: %s [%s], \r",volume, current_frame,
					playbuf->num_frames > 0 ? playbuf->num_frames - current_frame : 0, long_currenttime_str, long_remaintime_str);
			}
		}
		else if(count < 0)
		{
			if(options.opt & MPG321_ENABLE_BUFFER)
			{
//				sprintf(ao_time, "Frame# %5lu [%5lu], Time: %s [%s],                     \r", current_frame,
				sprintf(ao_time, "Frame# %5lu [%5lu], Time: %s [%s],                 \r", current_frame,
					playbuf->num_frames > 0 ? playbuf->num_frames - current_frame : 0, long_currenttime_str, long_remaintime_str);
			}
			else
			{
				
				fprintf(stderr, "Frame# %5lu [%5lu], Time: %s [%s],                      \r", current_frame,
					playbuf->num_frames > 0 ? playbuf->num_frames - current_frame : 0, long_currenttime_str, long_remaintime_str);
			}
		}
    }
    else if (options.opt & MPG321_REMOTE_PLAY)
    {
    
	    if (!options.skip_printing_frames 
            || (options.skip_printing_frames && !(current_frame % options.skip_printing_frames)))
	    {
		    if(options.opt & MPG321_ENABLE_BUFFER)
		    {
			    sprintf(ao_time,"@F %ld %ld %.2f %.2f\n", current_frame, playbuf->num_frames - current_frame,
				    	    ((double)mad_timer_count(current_time, MAD_UNITS_CENTISECONDS)/100.0),
			    		    ((double)mad_timer_count(time_remaining, MAD_UNITS_CENTISECONDS)/100.0));
		    }
		    else
		    {

			    fprintf(stderr,"@F %ld %ld %.2f %.2f\n", current_frame, playbuf->num_frames - current_frame,
				    	    ((double)mad_timer_count(current_time, MAD_UNITS_CENTISECONDS)/100.0),
			    		    ((double)mad_timer_count(time_remaining, MAD_UNITS_CENTISECONDS)/100.0));
		    }
	    }
    }
    return MAD_FLOW_CONTINUE;
}        
예제 #4
0
void LIBCOD_CALL server_detectversion( server_t *server ) {
    string buff = xmalloc( 1024 );

    int err = server_raw_socket( server, "\xff\xff\xff\xffgetinfo xxx", buff, 1024 );
    
    if ( err > 0 || indexof( buff, '\\', 0 ) < 0 ) {
        xfree( buff );
        spawn_error( "Error while running server_detectversion", false );
        return;
    }
        
    string infostring = substring( buff, indexof( buff, '\\', 0 ), strlen( buff ) );
    xfree( buff );
    
    string val = Info_ValueForKey( infostring, "protocol" );
    int gameversion = UNKNOWN;
    
    if ( strcmp( val, "" ) == 0 )
        return;
        
    int protocol = atoi( val );
    
    switch ( protocol ) {
        // Call of Duty
        case 1:     gameversion = COD_1_1;              break;
        case 2:     gameversion = COD_1_2;              break;
        case 4:     gameversion = COD_1_3;              break;
        case 5:     gameversion = COD_1_4;              break;
        case 6:     gameversion = COD_1_5;              break;

        // Call of Duty: United Offensive
        case 21:    gameversion = CODUO_1_41;           break;
        case 22:    gameversion = CODUO_1_51;           break;

        // Call of Duty 2
        case 115:   gameversion = COD2_1_0;             break;
        case 116:   gameversion = COD2_1_01;            break;
        case 117:   gameversion = COD2_1_2;             break;
        case 118:   gameversion = COD2_1_3;             break;

        // Call of Duty: World at War
        case 93:    gameversion = CODWAW_1_0;           break;
        case 94:    gameversion = CODWAW_1_0_1017;      break;
        case 95:    gameversion = CODWAW_1_1;           break;
        case 96:    gameversion = CODWAW_1_2;           break;
        case 97:    gameversion = CODWAW_1_3;           break;
        case 98:    gameversion = CODWAW_1_4;           break;
        case 99:    gameversion = CODWAW_1_5;           break;
        case 100:   gameversion = CODWAW_1_6;           break;
        case 101:   gameversion = CODWAW_1_7;           break;

        default:    break;
    }
    
    if ( gameversion == UNKNOWN ) {
        string voice = Info_ValueForKey( infostring, "voice" );
        if ( strcmp( voice, "" ) != 0 ) {    
            switch ( protocol ) {
                // Call of Duty 4
                case 0:     gameversion = COD4_1_1;             break;
                case 1:     gameversion = COD4_1_2;             break;
                case 2:     gameversion = COD4_1_3;             break;
                case 3:     gameversion = COD4_1_4;             break;
                case 4:     gameversion = COD4_1_5;             break;
                case 5:     gameversion = COD4_1_6;             break;
                case 6:     gameversion = COD4_1_7;             break;
                default:                                        break;
            }
        }
    }
    
    xfree( infostring );
    
    server->version = gameversion;
    server->versionstring = versionstring( gameversion );
}