Exemplo n.º 1
0
void
VideoMixerNode::ClearInput(media_input *input) {

	// initialize the input
	sprintf(input->name, "VideoMixer Input");
	input->node = Node();
	input->source = media_source::null;
	input->destination = media_destination::null;

	GetInputFormat(&input->format);
}
Exemplo n.º 2
0
void VideoMixerNode::GetFlavor(flavor_info *outInfo, int32 id)
{
	fprintf(stderr,"VideoMixerNode::GetFlavor\n");

	if (outInfo != NULL) {
		outInfo->internal_id = id;
		outInfo->name = "Haiku VideoMixer";
		outInfo->info = "A VideoMixerNode node mixes multiple video streams into a single stream.";
		outInfo->kinds = B_BUFFER_CONSUMER | B_BUFFER_PRODUCER;
		outInfo->flavor_flags = B_FLAVOR_IS_LOCAL;
		outInfo->possible_count = INT_MAX;	// no limit
		outInfo->in_format_count = 1;
		media_format *inFormats = new media_format[outInfo->in_format_count];
		GetInputFormat(&inFormats[0]);
		outInfo->in_formats = inFormats;
		outInfo->out_format_count = 1; // single output
		media_format *outFormats = new media_format[outInfo->out_format_count];
		GetOutputFormat(&outFormats[0]);
		outInfo->out_formats = outFormats;
	}
}
Exemplo n.º 3
0
Arquivo: main.cpp Projeto: 2lnx/bco
int32_t main (int32_t argc, char * argv[]) 
{
    char * inputFileName = argv[1];
    char * outputFileName = argv[2];
    FILE * inputFile = NULL;
    FILE * outputFile = NULL;
		
	bool malformed = argc < 2;
	
    // Parse the commandline and open the necessary files
    for (int32_t i = 1; i < argc; ++i) 
	{
		if (strcmp (argv[i], "-h") == 0)
		{
			malformed = true;
		}
		else
		{
			if (argv[i][0] == '-')
            {
				printf ("unknown option: %s\n", argv[i]);
				malformed = true;
			}
			else
			{
                if (inputFile == NULL) inputFile = fopen (inputFileName, "rb"); // the b is necessary for Windows -- ignored by Unix
                if(inputFile == NULL)
                {
                    fprintf(stderr," Cannot open file \"%s\"\n", inputFileName);
                    exit (1);
                }

                if (outputFile == NULL) outputFile = fopen (outputFileName, "w+b"); // the b is necessary for Windows -- ignored by Unix
                if(outputFile == NULL)
                {
                    fprintf(stderr," Cannot open file \"%s\"\n", outputFileName);
                    exit (1);
                }
			}
		}
				
		if (malformed)
		{
			break;
		}
	}
	
	if (!malformed) 
	{
        printf("Input file: %s\n", inputFileName);
        printf("Output file: %s\n", outputFileName);
        // So at this point we have the input and output files open. Need to determine what we're dealing with
        int32_t theError = 0;
        AudioFormatDescription inputFormat;
        AudioFormatDescription outputFormat;
        int32_t inputDataPos = 0, inputDataSize = 0;
        uint32_t inputFileType = 0; // 'caff' or 'WAVE'
        uint32_t outputFileType = 0; // 'caff' or 'WAVE'
        
        theError = GetInputFormat(inputFile, &inputFormat, &inputFileType);
        if (theError)
        {
            fprintf(stderr," Cannot determine what format file \"%s\" is\n", inputFileName);
            exit (1);            
        }
        
        if (inputFileType != 'WAVE' && inputFileType != 'caff')
        {
            fprintf(stderr," File \"%s\" is of an unsupported type\n", outputFileName);
            exit (1);                        
        }
        
        if (inputFormat.mFormatID != kALACFormatAppleLossless && inputFormat.mFormatID != kALACFormatLinearPCM)
        {
            fprintf(stderr," File \"%s\'s\" data format is of an unsupported type\n", outputFileName);
            exit (1);                        
        }

        SetOutputFormat(inputFormat, &outputFormat);

        if (theError)
        {
            fprintf(stderr," Cannot determine what format file \"%s\" is\n", outputFileName);
            exit (1);            
        }
        FindDataStart(inputFile, inputFileType, &inputDataPos, &inputDataSize);
        fseek(inputFile, inputDataPos, SEEK_SET);
        
        // We know where we are and we know what we're doing
        if (outputFormat.mFormatID == kALACFormatAppleLossless)
        {
            // encoding
            EncodeALAC(inputFile, outputFile, inputFormat, outputFormat, inputDataSize);
        }
        else
        {
            // decoding
            GetOutputFileType(outputFileName, &outputFileType);
            
            if (outputFileType == 'WAVE' && outputFormat.mChannelsPerFrame > 2)
            {
                // we don't support WAVE because we don't want to reinterleave on output 
                fprintf(stderr," Cannot decode more than two channels to WAVE\n");
                exit (1);            
            }
            DecodeALAC(inputFile, outputFile, inputFormat, outputFormat, inputDataSize, outputFileType);
        }
	}
	
	if (malformed) {
		printf ("Usage:\n");
		printf ("Encode:\n");
		printf ("        alacconvert <input wav or caf file> <output caf file>\n");
		printf ("Decode:\n");
		printf ("        alacconvert <input caf file> <output wav or caf file>\n");
		printf ("\n");
		return 1;
	}
	
    if (inputFile) fclose(inputFile);
    if (outputFile) fclose(outputFile);
    
	return 0;
}