static int probe_file(const char *filename) { InputFile ifile; int ret, i; ret = open_input_file(&ifile, filename); if (ret < 0) return ret; if (do_show_format) show_format(&ifile); if (do_show_streams) { probe_array_header("streams", 0); for (i = 0; i < ifile.nb_streams; i++) show_stream(&ifile, &ifile.streams[i]); probe_array_footer("streams", 0); } if (do_show_packets) show_packets(&ifile); close_input_file(&ifile); return 0; }
static int probe_file(const char *filename) { AVFormatContext *fmt_ctx; int ret, i; if ((ret = open_input_file(&fmt_ctx, filename))) return ret; if (do_show_streams) for (i = 0; i < fmt_ctx->nb_streams; i++) show_stream(fmt_ctx, i); if (do_show_format) show_format(fmt_ctx); av_close_input_file(fmt_ctx); return 0; }
static MSSndCard *ca_card_new(const char *name, const char * uidname, AudioDeviceID dev, unsigned cap) { MSSndCard *card = ms_snd_card_new(&ca_card_desc); AudioStreamBasicDescription format; AuCard *d = (AuCard *) card->data; unsigned int slen; int err; d->uidname = ms_strdup(uidname); d->dev = dev; card->name = ms_strdup(name); card->capabilities = cap; slen = sizeof(format); d->rate=44100; if (d->dev != -1) { err = AudioDeviceGetProperty(dev, 0, cap & MS_SND_CARD_CAP_CAPTURE, kAudioDevicePropertyStreamFormat, &slen, &format); if (err == kAudioHardwareNoError) { show_format("device", &format); d->rate=format.mSampleRate; } } return card; }
static int probe_file(const char *filename) { AVFormatContext *fmt_ctx; int ret, i; if ((ret = open_input_file(&fmt_ctx, filename))) return ret; if (do_show_format) show_format(fmt_ctx); if (do_show_streams) { probe_array_header("streams", 0); for (i = 0; i < fmt_ctx->nb_streams; i++) show_stream(fmt_ctx, i); probe_array_footer("streams", 0); } if (do_show_packets) show_packets(fmt_ctx); close_input_file(&fmt_ctx); return 0; }
static MSSndCard *ca_card_new(const char *name, const char * uidname, AudioDeviceID dev, unsigned cap) { MSSndCard *card = ms_snd_card_new(&ca_card_desc); AudioStreamBasicDescription format; AuCard *d = (AuCard *) card->data; UInt32 slen; int err; d->uidname = ms_strdup(uidname); card->name = ms_strdup_printf("%s (%s)", name, uidname); /*include uid so that names are uniques*/ card->capabilities = cap; slen = sizeof(format); d->rate=44100; if (dev != -1) { AudioObjectPropertyScope theScope = cap & MS_SND_CARD_CAP_CAPTURE ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; AudioObjectPropertyAddress theAddress = { kAudioDevicePropertyStreamFormat, theScope, 0 }; err = AudioObjectGetPropertyData(dev ,&theAddress ,0 ,NULL ,&slen ,&format); // err = AudioDeviceGetProperty(dev, 0, cap & MS_SND_CARD_CAP_CAPTURE, kAudioDevicePropertyStreamFormat, &slen, &format); if (err == kAudioHardwareNoError) { show_format("device", &format); d->rate=format.mSampleRate; } } return card; }
static int audio_unit_open(AUCommon *d, bool_t is_read) { OSStatus result; UInt32 param; ComponentDescription desc; Component comp; AudioStreamBasicDescription asbd; const int input_bus=1; const int output_bus=0; // Get Default Input audio unit desc.componentType = kAudioUnitType_Output; desc.componentSubType = d->dev!=-1?kAudioUnitSubType_HALOutput:kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; comp = FindNextComponent(NULL, &desc); if (comp == NULL) { ms_message("Cannot find audio component"); return -1; } result = OpenAComponent(comp, &d->au); if(result != noErr) { ms_message("Cannot open audio component %x", result); return -1; } param = is_read; if (d->dev!=-1) { CHECK_AURESULT(AudioUnitSetProperty(d->au, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, input_bus, ¶m, sizeof(UInt32))); param = !is_read; CHECK_AURESULT(AudioUnitSetProperty(d->au, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, output_bus, ¶m, sizeof(UInt32))); // Set the current device CHECK_AURESULT(AudioUnitSetProperty(d->au, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, output_bus, &d->dev, sizeof(AudioDeviceID))); } param=0; CHECK_AURESULT(AudioUnitSetProperty(d->au, kAudioUnitProperty_ShouldAllocateBuffer, is_read ? kAudioUnitScope_Input : kAudioUnitScope_Output , is_read ? input_bus : output_bus , ¶m, sizeof(param))); UInt32 asbdsize = sizeof(AudioStreamBasicDescription); memset((char *)&asbd, 0, asbdsize); CHECK_AURESULT(AudioUnitGetProperty(d->au, kAudioUnitProperty_StreamFormat, is_read ? kAudioUnitScope_Input : kAudioUnitScope_Output, is_read ? input_bus : output_bus, &asbd, &asbdsize)); show_format(is_read ? "Input audio unit" : "Output audio unit",&asbd); asbd.mSampleRate=d->rate; asbd.mBytesPerPacket=asbd.mBytesPerFrame = 2*d->nchannels; asbd.mChannelsPerFrame = d->nchannels; asbd.mBitsPerChannel=16; asbd.mFormatID=kAudioFormatLinearPCM; asbd.mFormatFlags=kAudioFormatFlagIsPacked|kAudioFormatFlagIsSignedInteger; CHECK_AURESULT(AudioUnitSetProperty(d->au, kAudioUnitProperty_StreamFormat, is_read ? kAudioUnitScope_Output : kAudioUnitScope_Input, is_read ? input_bus : output_bus , &asbd, sizeof(AudioStreamBasicDescription))); CHECK_AURESULT(AudioUnitGetProperty(d->au, kAudioUnitProperty_StreamFormat, is_read ? kAudioUnitScope_Output : kAudioUnitScope_Input, is_read ? input_bus : output_bus , &asbd, &asbdsize)); show_format(is_read ? "Input audio unit after configuration" : "Output audio unit after configuration",&asbd); // Get the number of frames in the IO buffer(s) param = sizeof(UInt32); UInt32 numFrames; CHECK_AURESULT(AudioUnitGetProperty(d->au, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Input, input_bus, &numFrames, ¶m)); ms_message("Number of frames per buffer = %i", numFrames); AURenderCallbackStruct cbs; cbs.inputProcRefCon = d; if (is_read) { cbs.inputProc = readRenderProc; CHECK_AURESULT(AudioUnitSetProperty(d->au, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, input_bus, &cbs, sizeof(AURenderCallbackStruct))); } else { cbs.inputProc = writeRenderProc; CHECK_AURESULT(AudioUnitSetProperty (d->au, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, output_bus, &cbs, sizeof(AURenderCallbackStruct))); } result = AudioUnitInitialize(d->au); if(result != noErr) { ms_error("failed to AudioUnitInitialize %i , is_read=%i", result,(int)is_read); return -1; } CHECK_AURESULT(AudioOutputUnitStart(d->au)); return 0; }
int main(int argc, char * argv[]) { cout << "The UNV Project - Server" << endl; cout << "Department of Electronic & Electrical Engineering" << endl; cout << "University College London" << endl << endl; // Read CLI Options, and error if not vaild if ( (argc<=1)||(get_options(argc, argv)) ) { fail("parsing CLI options", "couldn't understand options. Run with --help.", FALSE); exit(EXIT_SUCCESS); } // check that mandatory command line args are there... if ( (cliOpts.mode==NULL)||(cliOpts.devicepath==NULL)||(cliOpts.networkport==0)||(cliOpts.transport==4)||(cliOpts.vcodec==4) ) { printf("You must specify mode (-m), device (-d), network port (-p), network transport (-t) and a video codec (-c)\n"); fail("parsing CLI options", "Mandatory options missing! Run with --help.", FALSE); exit(EXIT_FAILURE); } // register all codecs, drivers, devics, etc so we know what we have. if (cliOpts.verbose) { cout << "Registering Codecs and Device drivers" << endl; } // Verbose // Init libav stuff avcodec_init(); av_register_all(); avdevice_register_all(); av_init_packet(&CurrentPacket); // Show version information if (cliOpts.version) { show_version(); exit(EXIT_SUCCESS); } // Show formats supported if asked. if (cliOpts.formats) { show_format(pInputFmtVidDec); exit(EXIT_SUCCESS); } // Before we get onto the deep stuff, check if we know what we're about... if ((cliOpts.devicepath == NULL) || (cliOpts.mode == NULL)) { fail("intialising", "device or mode not set.", TRUE); } // Program actually starts here - before was just checking stuffs // // Allocate codec context if (cliOpts.verbose) { cout << "Allocating memory for codec contexts" << endl; } pCodecCtxVidEnc = avcodec_alloc_context(); pCodecCtxVidDec = avcodec_alloc_context(); pCodecCtxAudDec = avcodec_alloc_context(); pCodecCtxAudEnc = avcodec_alloc_context(); if ( (pCodecCtxVidEnc == NULL) || (pCodecCtxVidDec == NULL) ) { fail("allocating frames", "couldn't allocate either pFrame of pFrameRGB", TRUE); } // Allocate Frames if (cliOpts.verbose) { cout << "Allocating memory for frames " << "\n"; } pFrameDec = avcodec_alloc_frame(); pFrameEnc = avcodec_alloc_frame(); pFrameRGB = avcodec_alloc_frame(); if ( (pFrameDec == NULL) || (pFrameEnc == NULL) || (pFrameRGB == NULL) ) { fail("allocating frames", "couldn't allocate either pFrame of pFrameRGB", TRUE); } // Get options for input type if (strcmp(cliOpts.mode, "file") == 0 || strcmp(cliOpts.mode, "file") == 0) { int temp; // File if (cliOpts.verbose) { cout << "Opening '" << cliOpts.devicepath << "' as input file" << "\n"; } // Verbose temp = av_open_input_file(&pFormatCtxVidDec, cliOpts.devicepath, NULL, 0, NULL); iFileOpen = av_open_input_file(&pFormatCtxAudDec,cliOpts.devicepath, NULL, 0, NULL); if(temp != 0) { AVERROR_LOOKUP(temp); fail("opening video", "couldn't open input file", TRUE); } if(iFileOpen != 0) { AVERROR_LOOKUP(iFileOpen); fail("opening audio", "couldn't open audio device", TRUE); } } else { int temp; // Video4Linux2 if (cliOpts.verbose) { cout << "Opening " << cliOpts.devicepath << " as Video4Linux2 device" << "\n"; } // Verbose FormatParamVidDec.channel = 0; FormatParamVidDec.standard = "pal"; // pal (or ntsc) FormatParamVidDec.width = cliOpts.width; // read from CLI FormatParamVidDec.height = cliOpts.height; // read from CLI FormatParamVidDec.time_base.num = 1; FormatParamVidDec.time_base.den = 15; pInputFmtVidDec = av_find_input_format("video4linux2"); /*FIXME*/ //temp = av_open_input_file(&pFormatCtxVidDec, cliOpts.devicepath, pInputFmtVidDec, 0, &FormatParamVidDec); // should take the FormatParamVidDec option, but seg faults. ///////////////////////////////////////// temp = av_open_input_file(&pFormatCtxVidDec, cliOpts.devicepath, pInputFmtVidDec, 0, NULL); if(temp !=0) { AVERROR_LOOKUP(temp); fail("opening video", "couldn't open input file", TRUE); } } // Set parameters FormatParamAudDec.sample_rate = SAMPLE_RATE; FormatParamAudDec.channels = CHANNELS; FormatParamAudDec.time_base = (AVRational){1, SAMPLE_RATE}; // FormatParamAudDec.audio_codec_id = CODEC_TYPE_AUDIO; // Find input format pInputFmtAudDec = av_find_input_format("alsa"); // Open device if (cliOpts.verbose) { cout << "Opening '" << "plughw:0,0" << "' as ALSA Audio device" << "\n"; } iFileOpen = av_open_input_file(&pFormatCtxAudDec, "plughw:0,0", pInputFmtAudDec, 0, &FormatParamAudDec); if (cliOpts.verbose) { cout << "av_open_input_file: " << iFileOpen << "\n"; } if(iFileOpen<0) { AVERROR_LOOKUP(iFileOpen); fail("opening video", "couldn't open audio device", TRUE); } if(iFileOpen==0 && cliOpts.verbose) { cout << "Opened successfully!" << "\n"; } // Retrieve stream information if (cliOpts.verbose) { cout << "Analysing video stream(s)" << "\n"; } { int temp; temp = av_find_stream_info(pFormatCtxVidDec); if(temp<0) { AVERROR_LOOKUP(temp); fail("finding stream", "couldn't find stream infomation", TRUE); } } // dump what we've found to stderr. if (cliOpts.verbose) { cerr << "Format Dump" << "\n"; dump_format(pFormatCtxVidDec, 0, cliOpts.devicepath, FALSE); } // Find the first video stream if (cliOpts.verbose) { cout << "Selecting first video stream" << "\n"; } iVideoStream=-1; for(int i=0; i<(int)pFormatCtxVidDec->nb_streams; i++) { if(pFormatCtxVidDec->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) { //modified codec.codec... to union in structure - GS iVideoStream=i; break; } } if(iVideoStream == -1) { fail("selecting stream", "couldn't select first stream", TRUE); } iAudioStream = -1; if (cliOpts.verbose) { // Look for audio stream cout << "Looking for audio stream..." << "\n"; } for (int i = 0; i < (int)pFormatCtxAudDec->nb_streams; i++){ // Loop through streams if (pFormatCtxAudDec->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO) { // If audio stream is found iAudioStream = i; break; } } if (cliOpts.verbose) { cout << "iAudioStream = " << iAudioStream << "\n"; } if (iAudioStream < 0 ) { fail("selecting stream", "couldn't select audio stream", TRUE); } // Get a pointer to the codec context for the video stream pCodecCtxVidDec=pFormatCtxVidDec->streams[iVideoStream]->codec; // removed address operator - GS // Find the decoder for the video stream pCodecVidDec=avcodec_find_decoder(pCodecCtxVidDec->codec_id); if(pCodecVidDec==NULL) { fail("finding decoder", "couldn't find required codec", TRUE); } // Populate AVCodecContext with info from stream pCodecCtxAudDec = pFormatCtxAudDec->streams[iAudioStream]->codec; if (pCodecCtxAudDec == NULL) { cerr << "Error: pCodecCtxAudDec is null!" << "\n"; return 1; } // Find decoder pCodecAudDec = avcodec_find_decoder(pCodecCtxAudDec->codec_id); if(pCodecAudDec==NULL) { fail("finding decoder", "couldn't find required codec", TRUE); } // Find the codec for our required format if (cliOpts.vcodec == USE_MJPEG) {pCodecVidEnc = avcodec_find_encoder(CODEC_ID_MJPEG);} if (cliOpts.vcodec == USE_H264) {pCodecVidEnc = avcodec_find_encoder(CODEC_ID_H264);} if (pCodecVidEnc == NULL) { fail("finding encoder", "couldn't find required codec", TRUE); } // X.264 Parameters if (cliOpts.vcodec == USE_H264) { pCodecCtxVidEnc->thread_count = 2; avcodec_thread_init(pCodecCtxVidEnc, pCodecCtxVidEnc->thread_count); pCodecCtxVidEnc->flags |= CODEC_FLAG_LOOP_FILTER; pCodecCtxVidEnc->me_cmp |= 1; pCodecCtxVidEnc->partitions |= X264_PART_I8X8+X264_PART_I4X4+X264_PART_P8X8+X264_PART_B8X8; pCodecCtxVidEnc->me_method = ME_HEX; pCodecCtxVidEnc->me_subpel_quality = 2; //c->me_range = 16; pCodecCtxVidEnc->keyint_min = 25; //c->scenechange_threshold=40; //c->qcompress = 0.6; pCodecCtxVidEnc->qmin = 10; pCodecCtxVidEnc->qmax = 51; pCodecCtxVidEnc->max_qdiff = 4; pCodecCtxVidEnc->max_b_frames = 0; pCodecCtxVidEnc->refs = 1; //c->directpred = 1; //c->trellis = 1; pCodecCtxVidEnc->flags2 |= CODEC_FLAG2_MIXED_REFS+CODEC_FLAG2_WPRED+CODEC_FLAG2_8X8DCT+CODEC_FLAG2_FASTPSKIP;//CODEC_FLAG2_BPYRAMID+ //c->weighted_p_pred = 2; pCodecCtxVidEnc->crf = 32; pCodecCtxVidEnc->rc_lookahead = 0; pCodecCtxVidEnc->gop_size = 10; //pCodecCtxVidEnc->time_base.den * 2; //250;// emit one intra frame every twelve frames at most //pCodecCtxVidEnc->pix_fmt = STREAM_PIX_FMT; pCodecCtxVidEnc->width = 640; pCodecCtxVidEnc->height = 480; pCodecCtxVidEnc->time_base=(AVRational){1,5}; // some formats want stream headers to be separate if(pCodecCtxVidEnc->flags & AVFMT_GLOBALHEADER) pCodecCtxVidEnc->flags |= CODEC_FLAG_GLOBAL_HEADER; if(cliOpts.transport==USE_TCP) {pCodecCtxVidEnc->bit_rate = 1000000; printf("Capping BR for TCP/H264\n");} if (cliOpts.verbose) { cout << "x264 configured" << "\n"; } } // MJPEG Parameters if (cliOpts.vcodec == USE_MJPEG) { pCodecCtxVidEnc->codec_type = CODEC_TYPE_VIDEO; pCodecCtxVidEnc->codec_id = CODEC_ID_MJPEG; pCodecCtxVidEnc->bit_rate = BITRATE; pCodecCtxVidEnc->width = pCodecCtxVidDec->width; pCodecCtxVidEnc->height = pCodecCtxVidDec->height; pCodecCtxVidEnc->time_base=(AVRational){1,25}; pCodecCtxVidEnc->pix_fmt = PIX_FMT_YUVJ420P;//YUVJ422P pCodecCtxVidEnc->color_range=AVCOL_RANGE_JPEG; pCodecCtxVidEnc->qmin= 90; pCodecCtxVidEnc->qmax= 90; if (cliOpts.verbose) { cout << "MJPEG configured" << "\n"; } } // Find encoder pCodecAudEnc = avcodec_find_encoder(CODEC_ID_MP3); if (pCodecAudEnc == NULL) { fail("Error:", "codec not found!", TRUE); return 1; } //Set encoder parameters pCodecCtxAudEnc->bit_rate = BITRATE; pCodecCtxAudEnc->sample_fmt = SAMPLE_FMT_S16; pCodecCtxAudEnc->sample_rate = SAMPLE_RATE; pCodecCtxAudEnc->channels = CHANNELS; //pCodecCtxAudEnc->profile = 1; //FF_PROFILE_AAC_MAIN; pCodecCtxAudEnc->time_base = (AVRational){1, SAMPLE_RATE}; pCodecCtxAudEnc->codec_type = CODEC_TYPE_AUDIO; // Open decoder if (cliOpts.verbose) { cout << "Opening codec (decoder)" << "\n"; } { int temp; temp = avcodec_open(pCodecCtxVidDec, pCodecVidDec); if(temp<0) { AVERROR_LOOKUP(temp); fail("opening codec", "couldn't open decoder codec", TRUE); } } // Open the encoder if (cliOpts.verbose) { cout << "Opening codec (encoder)" << "\n"; } { int temp; temp = avcodec_open(pCodecCtxVidEnc, pCodecVidEnc); if(temp < 0) { AVERROR_LOOKUP(temp); fail("opening codec", "couldn't open encoder codec", TRUE); } } // Open decoder iCodecOpen = avcodec_open(pCodecCtxAudDec, pCodecAudDec); if (cliOpts.verbose) { cout << "avcodec_open (decoder): " << iCodecOpen << "\n"; } if (iCodecOpen < 0 ) { AVERROR_LOOKUP(iCodecOpen); fail("opening codec", "couldn't open decoder codec", TRUE); } // Open encoder iOpenEncoder = avcodec_open(pCodecCtxAudEnc, pCodecAudEnc); if (cliOpts.verbose) { cout << "avcodec_open (encoder): " << iOpenEncoder << "\n"; } if(iOpenEncoder < 0) { AVERROR_LOOKUP(iOpenEncoder); fail("opening codec", "couldn't open encoder codec", TRUE); } // Allocate YUV and RGB memory. if (cliOpts.verbose) { cout << "Allocating format conversion colourspace" << "\n"; } iRGBFrameSize=avpicture_get_size(PIX_FMT_RGB24, pCodecCtxVidDec->width, pCodecCtxVidDec->height); iYUVFrameSize = avpicture_get_size(PIX_FMT_YUV420P, pCodecCtxVidEnc->width, pCodecCtxVidEnc->height); iOutBufferSize = 100000; if (cliOpts.verbose) { cout << " RGB: " << iRGBFrameSize << " Bytes\n YUV: " << iYUVFrameSize << " Bytes\n OUT: " << iOutBufferSize << " Bytes\n"; } pYUVBufferVid = (uint8_t *) malloc((iYUVFrameSize)); pRGBBufferVid = (uint8_t *) malloc(iRGBFrameSize); // check we got the buffer we wanted. if ( (pRGBBufferVid == NULL) || (pYUVBufferVid == NULL) ) { fail("malloc buffers", "couldn't allocate memory for pFrameRGB or pFrameEnc buffers", TRUE); } if (cliOpts.verbose) { cout << "Assigning RGB and YUV buffers to AVFrames.\n"; } // Assign appropriate parts of buffer to image planes in pFrameRGB and pFrameYUV avpicture_fill((AVPicture *)pFrameRGB, pRGBBufferVid, PIX_FMT_RGB24, pCodecCtxVidDec->width, pCodecCtxVidDec->height); // RGB size avpicture_fill((AVPicture *)pFrameEnc, pYUVBufferVid, PIX_FMT_YUV420P, pCodecCtxVidDec->width, pCodecCtxVidDec->height); // YUV size pOutBufferVid = (unsigned char *) av_malloc(iOutBufferSize * sizeof(uint8_t)); // alloc output buffer for encoded datastream // Allocate Encoding and Decoding Buffers AUDIO // Decode output buffer iOutbufDecSize = AVCODEC_MAX_AUDIO_FRAME_SIZE; outbufDec = (uint8_t *)av_malloc(iOutbufDecSize + FF_INPUT_BUFFER_PADDING_SIZE); // Encode output buffer iOutbufEncSize = 10000; outbufEnc = (uint8_t *)av_malloc(iOutbufEncSize); // if we want to save video if (cliOpts.savevideo) { // Open output file handle if (cliOpts.verbose) { cout << "Opening output video file" << "\n"; } pOutputVideo = fopen(cliOpts.videopath, "wb"); // Write Binary test=fopen("test.264","wb"); if ((pOutputVideo == NULL) && (test == NULL)) { cerr << "Could not open " << cliOpts.videopath << "\n"; fail("opening file handle", "couldn't open file", TRUE); } } // if we want to save the audio if (cliOpts.saveaudio) { // Open output file handle if (cliOpts.verbose) { cout << "Opening output audio file" << "\n"; } pOutputAudio = fopen(cliOpts.audiopath, "wb"); // Write Binary if (!pOutputAudio) { cerr << "Could not open " << cliOpts.audiopath << "\n"; fail("opening file handle", "couldn't open file", TRUE); } } // Stats file pStatisticsFile = fopen("stats.csv", "w"); if(cliOpts.networkport > 0) { // if the port is greater than 0, we requested it. startServerRTSP(20,cliOpts.networkport, (cliOpts.networkport + 5), cliOpts.transport); } if (cliOpts.verbose) { cout << "Entering main processing loop" << "\n"; cout << "If you would like to have this debugged, run with two verbose options.\nThis will slow the program a lot!\n"; } //boost::thread AudioThread(runAudioLoop); //timer start cout << "Spawning Server Child Thread" << endl; start = stampstart(); boost::thread VideoThread(runVideoLoop); // Setup Signal Catcher callback... // This lets us exit nicely once the program loop is running. cout << "Setting Signal Handler" <<endl; signal(SIGINT, signal_handler); // on signal, we call signal_handler with the sig type as an integer arg // fall through this when the stop flag is set. while(StopExecution == false) { usleep(10*1000*1000); } cout << "Parent Thread Stop Execution Requested" << endl; // report back to the user how many frames were processed. cout << (long) iFramesDecoded << " frames parsed" << "\n"; if (cliOpts.verbose) { cout << "Freeing memory " << "\n"; } // Free frame memory av_free(pFrameDec); av_free(pFrameEnc); av_free(pFrameRGB); free(pOutBufferVid); free(pRGBBufferVid); free(pYUVBufferVid); free(outbufDec); free(outbufEnc); if (cliOpts.verbose) { cout << "Freeing codecs " << "\n"; } // Close the codecs avcodec_close(pCodecCtxVidDec); avcodec_close(pCodecCtxVidEnc); avcodec_close(pCodecCtxAudDec); avcodec_close(pCodecCtxAudEnc); if (cliOpts.verbose) { cout << "Freeing I/O " << "\n"; } // Close video file av_close_input_file(pFormatCtxVidDec); // Close the video output file handle IF it was opened if (cliOpts.savevideo) { if (cliOpts.verbose) { cout << "Close Video Dump" << "\n"; } fclose(pOutputVideo); } // Close the audio output file handle IF it was opened if (cliOpts.saveaudio) { if (cliOpts.verbose) { cout << "Close Audio Dump" << "\n"; } fclose(pOutputAudio); } // close stats file fclose(pStatisticsFile); if (cliOpts.verbose) { cout <<"Exiting..." << "\n"; } exit(EXIT_SUCCESS); }
static void aq_start_w(MSFilter * f) { AQData *d = (AQData *) f->data; if (d->write_started == FALSE) { OSStatus aqresult; d->writeAudioFormat.mSampleRate = d->rate; d->writeAudioFormat.mFormatID = kAudioFormatLinearPCM; d->writeAudioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; d->writeAudioFormat.mFramesPerPacket = 1; d->writeAudioFormat.mChannelsPerFrame = 1; d->writeAudioFormat.mBitsPerChannel = d->bits; d->writeAudioFormat.mBytesPerPacket = d->bits / 8; d->writeAudioFormat.mBytesPerFrame = d->bits / 8; show_format("data provided to output filter", &d->writeAudioFormat); show_format("output device", &d->devicewriteFormat); memcpy(&d->devicewriteFormat, &d->writeAudioFormat, sizeof(d->writeAudioFormat)); d->writeBufferByteSize = kSecondsPerBuffer * d->devicewriteFormat.mSampleRate * (d->devicewriteFormat.mBitsPerChannel / 8) * d->devicewriteFormat.mChannelsPerFrame; #if 0 aqresult = AudioConverterNew(&d->writeAudioFormat, &d->devicewriteFormat, &d->writeAudioConverter); if (aqresult != noErr) { ms_error("d->writeAudioConverter = %d", aqresult); d->writeAudioConverter = NULL; } #endif // create the playback audio queue object aqresult = AudioQueueNewOutput(&d->devicewriteFormat, writeCallback, d, NULL, /*CFRunLoopGetCurrent () */ NULL, /*kCFRunLoopCommonModes */ 0, // run loop flags &d->writeQueue); if (aqresult != noErr) { ms_error("AudioQueueNewOutput = %d", aqresult); } AudioQueueSetParameter (d->writeQueue, kAudioQueueParam_Volume, gain_volume_out); if (d->uidname!=NULL){ char uidname[256]; CFStringGetCString(d->uidname, uidname, 256, CFStringGetSystemEncoding()); ms_message("AQ: using uidname:%s", uidname); aqresult = AudioQueueSetProperty(d->writeQueue, kAudioQueueProperty_CurrentDevice, &d->uidname, sizeof(CFStringRef)); if (aqresult != noErr) { ms_error ("AudioQueueSetProperty on kAudioQueueProperty_CurrentDevice %d", aqresult); } } setupWrite(f); d->curWriteBuffer = 0; } }
static void aqcard_detect(MSSndCardManager * m) { #ifndef TARGET_OS_IPHONE OSStatus err; UInt32 slen; int count; Boolean writable; int i; writable = 0; slen = 0; err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &slen, &writable); if (err != kAudioHardwareNoError) { ms_error("get kAudioHardwarePropertyDevices error %ld", err); return; } AudioDeviceID V[slen / sizeof(AudioDeviceID)]; err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &slen, V); if (err != kAudioHardwareNoError) { ms_error("get kAudioHardwarePropertyDevices error %ld", err); return; } count = slen / sizeof(AudioDeviceID); for (i = 0; i < count; i++) { char devname_in[256]; char uidname_in[256]; char devname_out[256]; char uidname_out[256]; int cap = 0; /* OUTPUT CARDS */ slen = 256; err = AudioDeviceGetProperty(V[i], 0, FALSE, kAudioDevicePropertyDeviceName, &slen, devname_out); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); continue; } slen = strlen(devname_out); /* trim whitespace */ while ((slen > 0) && (devname_out[slen - 1] == ' ')) { slen--; } devname_out[slen] = '\0'; err = AudioDeviceGetPropertyInfo(V[i], 0, FALSE, kAudioDevicePropertyStreamConfiguration, &slen, &writable); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); continue; } AudioBufferList *buflist = ms_malloc(slen); if (buflist == NULL) { ms_error("alloc AudioBufferList %ld", err); continue; } err = AudioDeviceGetProperty(V[i], 0, FALSE, kAudioDevicePropertyStreamConfiguration, &slen, buflist); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); ms_free(buflist); continue; } UInt32 j; for (j = 0; j < buflist->mNumberBuffers; j++) { if (buflist->mBuffers[j].mNumberChannels > 0) { cap = MS_SND_CARD_CAP_PLAYBACK; break; } } ms_free(buflist); /* INPUT CARDS */ slen = 256; err = AudioDeviceGetProperty(V[i], 0, TRUE, kAudioDevicePropertyDeviceName, &slen, devname_in); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); continue; } slen = strlen(devname_in); /* trim whitespace */ while ((slen > 0) && (devname_in[slen - 1] == ' ')) { slen--; } devname_in[slen] = '\0'; err = AudioDeviceGetPropertyInfo(V[i], 0, TRUE, kAudioDevicePropertyStreamConfiguration, &slen, &writable); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); continue; } err = AudioDeviceGetPropertyInfo(V[i], 0, TRUE, kAudioDevicePropertyStreamConfiguration, &slen, &writable); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); continue; } buflist = ms_malloc(slen); if (buflist == NULL) { ms_error("alloc error %ld", err); continue; } err = AudioDeviceGetProperty(V[i], 0, TRUE, kAudioDevicePropertyStreamConfiguration, &slen, buflist); if (err != kAudioHardwareNoError) { ms_error("get kAudioDevicePropertyDeviceName error %ld", err); ms_free(buflist); continue; } for (j = 0; j < buflist->mNumberBuffers; j++) { if (buflist->mBuffers[j].mNumberChannels > 0) { cap |= MS_SND_CARD_CAP_CAPTURE; break; } } ms_free(buflist); if (cap & MS_SND_CARD_CAP_PLAYBACK) { CFStringRef dUID_out; dUID_out = NULL; slen = sizeof(CFStringRef); err = AudioDeviceGetProperty(V[i], 0, false, kAudioDevicePropertyDeviceUID, &slen, &dUID_out); if (err != kAudioHardwareNoError) { ms_error("get kAudioHardwarePropertyDevices error %ld", err); continue; } CFStringGetCString(dUID_out, uidname_out, 256, CFStringGetSystemEncoding()); ms_message("AQ: devname_out:%s uidname_out:%s", devname_out, uidname_out); AudioStreamBasicDescription devicewriteFormat; slen = sizeof(devicewriteFormat); err = AudioDeviceGetProperty(V[i], 0, false, kAudioDevicePropertyStreamFormat, &slen, &devicewriteFormat); if (err == kAudioHardwareNoError) { show_format("output device", &devicewriteFormat); } MSSndCard *card = aq_card_new(devname_out, dUID_out, NULL, &devicewriteFormat, MS_SND_CARD_CAP_PLAYBACK); ms_snd_card_manager_add_card(m, card); } if (cap & MS_SND_CARD_CAP_CAPTURE) { CFStringRef dUID_in; dUID_in = NULL; slen = sizeof(CFStringRef); err = AudioDeviceGetProperty(V[i], 0, true, kAudioDevicePropertyDeviceUID, &slen, &dUID_in); if (err != kAudioHardwareNoError) { ms_error("get kAudioHardwarePropertyDevices error %ld", err); continue; } CFStringGetCString(dUID_in, uidname_in, 256, CFStringGetSystemEncoding()); ms_message("AQ: devname_in:%s uidname_in:%s", devname_in, uidname_in); AudioStreamBasicDescription devicereadFormat; slen = sizeof(devicereadFormat); err = AudioDeviceGetProperty(V[i], 0, true, kAudioDevicePropertyStreamFormat, &slen, &devicereadFormat); if (err == kAudioHardwareNoError) { show_format("input device", &devicereadFormat); } MSSndCard *card = aq_card_new(devname_in, dUID_in, &devicereadFormat, NULL, MS_SND_CARD_CAP_CAPTURE); ms_snd_card_manager_add_card(m, card); } } #else AudioStreamBasicDescription deviceFormat; memset(&deviceFormat, 0, sizeof(AudioStreamBasicDescription)); MSSndCard *card = aq_card_new("Audio Queue Device", NULL, &deviceFormat, &deviceFormat, MS_SND_CARD_CAP_PLAYBACK|MS_SND_CARD_CAP_CAPTURE); ms_snd_card_manager_add_card(m, card); #endif }
/* return TRUE if a command match, FALSE if not */ static TBOOLEAN show_two() { if (almost_equals(c_token, "p$lot")) { (void) putc('\n', stderr); show_plot(); c_token++; } else if (almost_equals(c_token, "par$ametric")) { (void) putc('\n', stderr); show_parametric(); c_token++; } else if (almost_equals(c_token, "poi$ntsize")) { (void) putc('\n', stderr); show_pointsize(); c_token++; } else if (almost_equals(c_token, "enc$oding")) { (void) putc('\n', stderr); show_encoding(); c_token++; } else if (almost_equals(c_token, "pol$ar")) { (void) putc('\n', stderr); show_polar(); c_token++; } else if (almost_equals(c_token, "an$gles")) { (void) putc('\n', stderr); show_angles(); c_token++; } else if (almost_equals(c_token, "ti$cs")) { (void) putc('\n', stderr); show_tics(TRUE, TRUE, TRUE, TRUE, TRUE); c_token++; } else if (almost_equals(c_token, "tim$estamp")) { (void) putc('\n', stderr); show_xyzlabel("time", &timelabel); fprintf(stderr, "\twritten in %s corner\n", (timelabel_bottom ? "bottom" : "top")); if (timelabel_rotate) fputs("\trotated if the terminal allows it\n\t", stderr); else fputs("\tnot rotated\n\t", stderr); c_token++; } else if (almost_equals(c_token, "su$rface")) { (void) putc('\n', stderr); show_surface(); c_token++; } else if (almost_equals(c_token, "hi$dden3d")) { (void) putc('\n', stderr); show_hidden3d(); c_token++; } else if (almost_equals(c_token, "cla$bel")) { (void) putc('\n', stderr); show_label_contours(); c_token++; } else if (almost_equals(c_token, "xti$cs")) { show_tics(TRUE, FALSE, FALSE, TRUE, FALSE); c_token++; } else if (almost_equals(c_token, "yti$cs")) { show_tics(FALSE, TRUE, FALSE, FALSE, TRUE); c_token++; } else if (almost_equals(c_token, "zti$cs")) { show_tics(FALSE, FALSE, TRUE, FALSE, FALSE); c_token++; } else if (almost_equals(c_token, "x2ti$cs")) { show_tics(FALSE, FALSE, FALSE, TRUE, FALSE); c_token++; } else if (almost_equals(c_token, "y2ti$cs")) { show_tics(FALSE, FALSE, FALSE, FALSE, TRUE); c_token++; } else if (almost_equals(c_token, "xdti$cs")) { show_tics(TRUE, FALSE, FALSE, TRUE, FALSE); c_token++; } else if (almost_equals(c_token, "ydti$cs")) { show_tics(FALSE, TRUE, FALSE, FALSE, TRUE); c_token++; } else if (almost_equals(c_token, "zdti$cs")) { show_tics(FALSE, FALSE, TRUE, FALSE, FALSE); c_token++; } else if (almost_equals(c_token, "x2dti$cs")) { show_tics(FALSE, FALSE, FALSE, TRUE, FALSE); c_token++; } else if (almost_equals(c_token, "y2dti$cs")) { show_tics(FALSE, FALSE, FALSE, FALSE, TRUE); c_token++; } else if (almost_equals(c_token, "xmti$cs")) { show_tics(TRUE, FALSE, FALSE, TRUE, FALSE); c_token++; } else if (almost_equals(c_token, "ymti$cs")) { show_tics(FALSE, TRUE, FALSE, FALSE, TRUE); c_token++; } else if (almost_equals(c_token, "zmti$cs")) { show_tics(FALSE, FALSE, TRUE, FALSE, FALSE); c_token++; } else if (almost_equals(c_token, "x2mti$cs")) { show_tics(FALSE, FALSE, FALSE, TRUE, FALSE); c_token++; } else if (almost_equals(c_token, "y2mti$cs")) { show_tics(FALSE, FALSE, FALSE, FALSE, TRUE); c_token++; } else if (almost_equals(c_token, "sa$mples")) { (void) putc('\n', stderr); show_samples(); c_token++; } else if (almost_equals(c_token, "isosa$mples")) { (void) putc('\n', stderr); show_isosamples(); c_token++; } else if (almost_equals(c_token, "si$ze")) { (void) putc('\n', stderr); show_size(); c_token++; } else if (almost_equals(c_token, "orig$in")) { (void) putc('\n', stderr); show_origin(); c_token++; } else if (almost_equals(c_token, "t$erminal")) { (void) putc('\n', stderr); show_term(); c_token++; } else if (almost_equals(c_token, "rr$ange")) { (void) putc('\n', stderr); show_range(R_AXIS, rmin, rmax, autoscale_r, "r"); c_token++; } else if (almost_equals(c_token, "tr$ange")) { (void) putc('\n', stderr); show_range(T_AXIS, tmin, tmax, autoscale_t, "t"); c_token++; } else if (almost_equals(c_token, "ur$ange")) { (void) putc('\n', stderr); show_range(U_AXIS, umin, umax, autoscale_u, "u"); c_token++; } else if (almost_equals(c_token, "vi$ew")) { (void) putc('\n', stderr); show_view(); c_token++; } else if (almost_equals(c_token, "vr$ange")) { (void) putc('\n', stderr); show_range(V_AXIS, vmin, vmax, autoscale_v, "v"); c_token++; } else if (almost_equals(c_token, "v$ariables")) { show_variables(); c_token++; } else if (almost_equals(c_token, "ve$rsion")) { show_version(stderr); } else if (almost_equals(c_token, "xr$ange")) { (void) putc('\n', stderr); show_range(FIRST_X_AXIS, xmin, xmax, autoscale_x, "x"); c_token++; } else if (almost_equals(c_token, "yr$ange")) { (void) putc('\n', stderr); show_range(FIRST_Y_AXIS, ymin, ymax, autoscale_y, "y"); c_token++; } else if (almost_equals(c_token, "x2r$ange")) { (void) putc('\n', stderr); show_range(SECOND_X_AXIS, x2min, x2max, autoscale_x2, "x2"); c_token++; } else if (almost_equals(c_token, "y2r$ange")) { (void) putc('\n', stderr); show_range(SECOND_Y_AXIS, y2min, y2max, autoscale_y2, "y2"); c_token++; } else if (almost_equals(c_token, "zr$ange")) { (void) putc('\n', stderr); show_range(FIRST_Z_AXIS, zmin, zmax, autoscale_z, "z"); c_token++; } else if (almost_equals(c_token, "z$ero")) { (void) putc('\n', stderr); show_zero(); c_token++; } else if (almost_equals(c_token, "a$ll")) { c_token++; show_version(stderr); show_autoscale(); show_bars(); show_border(); show_boxwidth(); show_clip(); show_contour(); show_dgrid3d(); show_mapping(); (void) fprintf(stderr, "\tdummy variables are \"%s\" and \"%s\"\n", dummy_var[0], dummy_var[1]); show_format(); show_style("data", data_style); show_style("functions", func_style); show_grid(); show_xzeroaxis(); show_yzeroaxis(); show_label(0); show_arrow(0); show_linestyle(0); show_keytitle(); show_key(); show_logscale(); show_offsets(); show_margin(); show_output(); show_parametric(); show_pointsize(); show_encoding(); show_polar(); show_angles(); show_samples(); show_isosamples(); show_view(); show_surface(); #ifndef LITE show_hidden3d(); #endif show_size(); show_origin(); show_term(); show_tics(TRUE, TRUE, TRUE, TRUE, TRUE); show_mtics(mxtics, mxtfreq, "x"); show_mtics(mytics, mytfreq, "y"); show_mtics(mztics, mztfreq, "z"); show_mtics(mx2tics, mx2tfreq, "x2"); show_mtics(my2tics, my2tfreq, "y2"); show_xyzlabel("time", &timelabel); if (parametric || polar) { if (!is_3d_plot) show_range(T_AXIS, tmin, tmax, autoscale_t, "t"); else { show_range(U_AXIS, umin, umax, autoscale_u, "u"); show_range(V_AXIS, vmin, vmax, autoscale_v, "v"); } } show_range(FIRST_X_AXIS, xmin, xmax, autoscale_x, "x"); show_range(FIRST_Y_AXIS, ymin, ymax, autoscale_y, "y"); show_range(SECOND_X_AXIS, x2min, x2max, autoscale_x2, "x2"); show_range(SECOND_Y_AXIS, y2min, y2max, autoscale_y2, "y2"); show_range(FIRST_Z_AXIS, zmin, zmax, autoscale_z, "z"); show_xyzlabel("title", &title); show_xyzlabel("xlabel", &xlabel); show_xyzlabel("ylabel", &ylabel); show_xyzlabel("zlabel", &zlabel); show_xyzlabel("x2label", &x2label); show_xyzlabel("y2label", &y2label); show_datatype("xdata", FIRST_X_AXIS); show_datatype("ydata", FIRST_Y_AXIS); show_datatype("x2data", SECOND_X_AXIS); show_datatype("y2data", SECOND_Y_AXIS); show_datatype("zdata", FIRST_Z_AXIS); show_timefmt(); show_locale(); show_zero(); show_missing(); show_plot(); show_variables(); show_functions(); c_token++; } else return (FALSE); return (TRUE); }
/* return TRUE if a command match, FALSE if not */ static TBOOLEAN show_one() { if (almost_equals(c_token, "ac$tion_table") || equals(c_token, "at")) { c_token++; show_at(); c_token++; } else if (almost_equals(c_token, "ar$row")) { struct value a; int tag = 0; c_token++; if (!END_OF_COMMAND) { tag = (int) real(const_express(&a)); if (tag <= 0) int_error("tag must be > zero", c_token); } (void) putc('\n', stderr); show_arrow(tag); } else if (almost_equals(c_token, "au$toscale")) { (void) putc('\n', stderr); show_autoscale(); c_token++; } else if (almost_equals(c_token, "b$ars")) { (void) putc('\n', stderr); show_bars(); c_token++; } else if (almost_equals(c_token, "bor$der")) { (void) putc('\n', stderr); show_border(); c_token++; } else if (almost_equals(c_token, "box$width")) { (void) putc('\n', stderr); show_boxwidth(); c_token++; } else if (almost_equals(c_token, "c$lip")) { (void) putc('\n', stderr); show_clip(); c_token++; } else if (almost_equals(c_token, "ma$pping")) { (void) putc('\n', stderr); show_mapping(); c_token++; } else if (almost_equals(c_token, "co$ntour") || almost_equals(c_token, "cn$trparam")) { (void) putc('\n', stderr); show_contour(); c_token++; } else if (almost_equals(c_token, "da$ta")) { c_token++; if (!almost_equals(c_token, "s$tyle")) int_error("expecting keyword 'style'", c_token); (void) putc('\n', stderr); show_style("data", data_style); c_token++; } else if (almost_equals(c_token, "dg$rid3d")) { (void) putc('\n', stderr); show_dgrid3d(); c_token++; } else if (almost_equals(c_token, "du$mmy")) { (void) fprintf(stderr, "\n\tdummy variables are \"%s\" and \"%s\"\n", dummy_var[0], dummy_var[1]); c_token++; } else if (almost_equals(c_token, "fo$rmat")) { show_format(); c_token++; } else if (almost_equals(c_token, "fu$nctions")) { c_token++; if (almost_equals(c_token, "s$tyle")) { (void) putc('\n', stderr); show_style("functions", func_style); c_token++; } else show_functions(); } else if (almost_equals(c_token, "lo$gscale")) { (void) putc('\n', stderr); show_logscale(); c_token++; } else if (almost_equals(c_token, "of$fsets")) { (void) putc('\n', stderr); show_offsets(); c_token++; } else if (almost_equals(c_token, "ma$rgin")) { (void) putc('\n', stderr); show_margin(); c_token++; } else if (almost_equals(c_token, "o$utput")) { (void) putc('\n', stderr); show_output(); c_token++; } else if (almost_equals(c_token, "tit$le")) { (void) putc('\n', stderr); show_xyzlabel("title", &title); c_token++; } else if (almost_equals(c_token, "mis$sing")) { (void) putc('\n', stderr); show_missing(); c_token++; } else if (almost_equals(c_token, "xl$abel")) { (void) putc('\n', stderr); show_xyzlabel("xlabel", &xlabel); c_token++; } else if (almost_equals(c_token, "x2l$abel")) { (void) putc('\n', stderr); show_xyzlabel("x2label", &x2label); c_token++; } else if (almost_equals(c_token, "yl$abel")) { (void) putc('\n', stderr); show_xyzlabel("ylabel", &ylabel); c_token++; } else if (almost_equals(c_token, "y2l$abel")) { (void) putc('\n', stderr); show_xyzlabel("y2label", &y2label); c_token++; } else if (almost_equals(c_token, "zl$abel")) { (void) putc('\n', stderr); show_xyzlabel("zlabel", &zlabel); c_token++; } else if (almost_equals(c_token, "keyt$itle")) { (void) putc('\n', stderr); show_keytitle(); c_token++; } else if (almost_equals(c_token, "xda$ta")) { (void) putc('\n', stderr); show_datatype("xdata", FIRST_X_AXIS); c_token++; } else if (almost_equals(c_token, "yda$ta")) { (void) putc('\n', stderr); show_datatype("ydata", FIRST_Y_AXIS); c_token++; } else if (almost_equals(c_token, "x2da$ta")) { (void) putc('\n', stderr); show_datatype("x2data", SECOND_X_AXIS); c_token++; } else if (almost_equals(c_token, "y2da$ta")) { (void) putc('\n', stderr); show_datatype("y2data", SECOND_Y_AXIS); c_token++; } else if (almost_equals(c_token, "zda$ta")) { (void) putc('\n', stderr); show_datatype("zdata", FIRST_Z_AXIS); c_token++; } else if (almost_equals(c_token, "timef$mt")) { (void) putc('\n', stderr); show_timefmt(); c_token++; } else if (almost_equals(c_token, "loca$le")) { (void) putc('\n', stderr); show_locale(); c_token++; } else if (almost_equals(c_token, "xzero$axis")) { (void) putc('\n', stderr); show_xzeroaxis(); c_token++; } else if (almost_equals(c_token, "yzero$axis")) { (void) putc('\n', stderr); show_yzeroaxis(); c_token++; } else if (almost_equals(c_token, "zeroa$xis")) { (void) putc('\n', stderr); show_xzeroaxis(); show_yzeroaxis(); c_token++; } else if (almost_equals(c_token, "la$bel")) { struct value a; int tag = 0; c_token++; if (!END_OF_COMMAND) { tag = (int) real(const_express(&a)); if (tag <= 0) int_error("tag must be > zero", c_token); } (void) putc('\n', stderr); show_label(tag); } else if (almost_equals(c_token, "li$nestyle") || equals(c_token, "ls")) { struct value a; int tag = 0; c_token++; if (!END_OF_COMMAND) { tag = (int) real(const_express(&a)); if (tag <= 0) int_error("tag must be > zero", c_token); } (void) putc('\n', stderr); show_linestyle(tag); } else if (almost_equals(c_token, "g$rid")) { (void) putc('\n', stderr); show_grid(); c_token++; } else if (almost_equals(c_token, "mxt$ics")) { (void) putc('\n', stderr); show_mtics(mxtics, mxtfreq, "x"); c_token++; } else if (almost_equals(c_token, "myt$ics")) { (void) putc('\n', stderr); show_mtics(mytics, mytfreq, "y"); c_token++; } else if (almost_equals(c_token, "mzt$ics")) { (void) putc('\n', stderr); show_mtics(mztics, mztfreq, "z"); c_token++; } else if (almost_equals(c_token, "mx2t$ics")) { (void) putc('\n', stderr); show_mtics(mx2tics, mx2tfreq, "x2"); c_token++; } else if (almost_equals(c_token, "my2t$ics")) { (void) putc('\n', stderr); show_mtics(my2tics, my2tfreq, "y2"); c_token++; } else if (almost_equals(c_token, "k$ey")) { (void) putc('\n', stderr); show_key(); c_token++; } else return (FALSE); return TRUE; }