BParameterWeb	*VideoRecorderNode::GetParameterWeb(void)
{
	int32 cookie = 0;
	bool first=true;
	media_file_format *mff=new media_file_format;
//	if (web) delete web;
	web = new BParameterWeb();
	BParameterGroup *videoFormat=web->MakeGroup("VideoFormat");
	BParameterGroup *formatGroup = videoFormat->MakeGroup("Fileformat");
	format = formatGroup->MakeDiscreteParameter(VIDEO_FORMAT, B_MEDIA_RAW_VIDEO, "VideoFileFormat", "FileFormat");
	BParameterGroup *codecGroup = videoFormat->MakeGroup("Codec");
	codec = codecGroup->MakeDiscreteParameter(VIDEO_CODEC, B_MEDIA_RAW_VIDEO, "Codec", "Codec");
	BParameterGroup *qualityGroup = videoFormat->MakeGroup("Quality");
	quality = qualityGroup->MakeContinuousParameter(VIDEO_QUALITY, B_MEDIA_RAW_VIDEO, "Video Quality", B_QUALITY,"",0,1.0,0.005);
	while (get_next_file_format(&cookie, mff) == B_OK)
	{
		if (mff->capabilities & media_file_format::B_KNOWS_ENCODED_VIDEO)
		{
//			format->AddItem(formatList->CountItems(), mff->pretty_name);
			format->AddItem((uint32)mff->family, mff->pretty_name);

			formatList->AddItem(&(mff->family));
			if (first)
			{
				videoFileFormat=*mff;
				BuildCodecMenu(videoFileFormat.family);
				first=false;
			}
		}
	}
	videoQuality=1.0;
	return web;	
}
Example #2
0
static BMediaFile*
init_media_file(media_format format, BMediaTrack** _track)
{
	static BMediaFile* file = NULL;
	static BMediaTrack* track = NULL;
	if (file == NULL) {
		entry_ref ref;
		get_ref_for_path("/boot/home/Desktop/test.wav", &ref);

		media_file_format fileFormat;
		int32 cookie = 0;
		while (get_next_file_format(&cookie, &fileFormat) == B_OK) {
			if (strcmp(fileFormat.short_name, "wav") == 0) {
				break;
			}
		}
		file = new BMediaFile(&ref, &fileFormat);

		media_codec_info info;
		cookie = 0;
		while (get_next_encoder(&cookie, &info) == B_OK) {
			if (strcmp(info.short_name, "raw-audio") == 0)
				break;
		}

		track = file->CreateTrack(&format, &info);
		if (!track)
			printf("failed to create track\n");

		file->CommitHeader();
	}
	*_track = track;
	return track != NULL ? file : NULL;
}
void
MediaConverterWindow::BuildFormatMenu()
{
	BMenu* menu = fFormatMenu->Menu();
	BMenuItem* item;

	// clear out old format menu items
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	// add menu items for each file format
	media_file_format mfi;
	int32 cookie = 0;
	FileFormatMenuItem* ff_item;
	while (get_next_file_format(&cookie, &mfi) == B_OK) {
		if ((mfi.capabilities & media_file_format::B_WRITABLE) == 0)
			continue;
		ff_item = new FileFormatMenuItem(&mfi);
		menu->AddItem(ff_item);
	}

	// mark first item
	item = menu->ItemAt(0);
	if (item != NULL) {
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	}
}
void 
VideoRecorderNode::BuildCodecMenu(media_format_family mf_family)
{
	LockParameterWeb();
	INFO("VideoRecorderNode::BuildCodecMenu()");
	// remember the currently-selected codec
/*	media_codec_info current_codec= *((media_codec_info *)(codecList->ItemAt(videoCodec)));
	int32 current = current_codec.id;	// remember the current codec
	current_codec.id = -2;						// magic invalid value*/

	// find the full media_file_format corresponding to the given format family (e.g. AVI)
	status_t err;
	media_file_format mff;
	int32 cookie = 0;
	while ((err = get_next_file_format(&cookie, &mff)) == B_OK)
	{
		if (mff.family == mf_family) break;
	}

	// hmm, something is desperately wrong -- we couldn't find the "current" format family
	if (err)
	{
		fprintf(stderr, "ERROR:  couldn't find current media format family\n");
		//*** we need some other error handling..
//		exit(1);
	}

	codec->MakeEmpty();
	void *item;
	while ((item = codecList->RemoveItem(int32(0))) != NULL)
	{
		delete item;
	}
	codecList->MakeEmpty();

	// fill in the list of available codecs for this media format and file family
	media_codec_info *codec_info=new media_codec_info;
//	media_codec_info firstCodec;
	media_format outFormat;
	cookie = 0;
	while (get_next_encoder(&cookie, &mff, &filterInput.format, &outFormat, codec_info) == B_OK)
	{
		codec->AddItem(codecList->CountItems(),codec_info->pretty_name);
		codecList->AddItem(codec_info);
		codec_info=new media_codec_info;
		videoCodec=1;
	}
	UnlockParameterWeb();
	//** Select one???
//	SetParameterWeb(web);
}
Example #5
0
// If prettyName is NULL, returns the first found media_file_format,
// otherwise returns the media_file_format with the same prettyName
// TODO: Use the short_name instead
static bool
get_media_file_format(const char* prettyName, media_file_format* outFormat)
{
	const uint32 mediaFormatMask = media_file_format::B_KNOWS_ENCODED_VIDEO
								| media_file_format::B_WRITABLE;								
	media_file_format mediaFileFormat;
	int32 cookie = 0;
	while (get_next_file_format(&cookie, &mediaFileFormat) == B_OK) {
		if ((mediaFileFormat.capabilities & mediaFormatMask) == mediaFormatMask
			&& (prettyName == NULL
				|| strcmp(mediaFileFormat.pretty_name, prettyName) == 0)) {
			*outFormat = mediaFileFormat;
			return true;
		}
	}
	
	return false;
}
Example #6
0
OutputView::OutputView(Controller *controller)
	:
	BView("Capture Options", B_WILL_DRAW),
	fController(controller)
{
	SetLayout(new BGroupLayout(B_VERTICAL));
	
	BBox *selectBox = new BBox("selection");
	selectBox->SetLabel("Selection");
	selectBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
	AddChild(selectBox);
	
	BBox *outputBox = new BBox("output");
	outputBox->SetLabel("Output");
	outputBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
	AddChild(outputBox);

	Settings settings;
	
	const char *kTCLabel = "File name:"; 
	const char *fileName = NULL;
	settings.GetOutputFileName(&fileName);
	fFileName = new BTextControl("file name",
			kTCLabel, fileName, new BMessage(kFileNameChanged));
	
	const char *kOutputMenuLabel = "Output Format:";
	fOutputFileType = new BOptionPopUp("OutFormat",
			kOutputMenuLabel, new BMessage(kFileTypeChanged));
						
	const char *kCodecMenuLabel = "Codec:";
	BPopUpMenu *popUpMenu = new BPopUpMenu("Codecs");
	fCodecMenu = new BMenuField("OutCodec", kCodecMenuLabel, popUpMenu);
	
	fWholeScreen = new BRadioButton("screen frame", "Whole screen",
		new BMessage(kCheckBoxAreaSelectionChanged));
	fCustomArea = new BRadioButton("custom area",
		"Custom Area", new BMessage(kCheckBoxAreaSelectionChanged));
	fSelectArea = new BButton("select area", "Select", new BMessage(kSelectArea));
	fSelectArea->SetEnabled(false);
	
	fMinimizeOnStart = new BCheckBox("Minimize on start",
		"Minimize on recording", new BMessage(kMinimizeOnRecording));
	
	fRectView = new PreviewView();
	
	BView *layoutView = BLayoutBuilder::Group<>()
		.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
			B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
			.Add(fFileName)
			.Add(fOutputFileType)
			.Add(fCodecMenu)
			.Add(fMinimizeOnStart)
		.End()	
		.View();

	outputBox->AddChild(layoutView);

	layoutView = BLayoutBuilder::Group<>()
		.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
			B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL)
			.AddGroup(B_HORIZONTAL)
				.AddGroup(B_VERTICAL, 0)
					.Add(fWholeScreen)
					.Add(fCustomArea)
				.End()
				.AddGroup(B_VERTICAL)
					.AddGlue()
					.Add(fSelectArea)
				.End()
			.End()
			.Add(fRectView)
		.End()
		.View();
	
	selectBox->AddChild(layoutView);

	fMinimizeOnStart->SetValue(settings.MinimizeOnRecording() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	// fill in the list of available file formats
	media_file_format mff;
	
	int32 cookie = 0;
	bool firstFound = true;
	while (get_next_file_format(&cookie, &mff) == B_OK) {
		if (mff.capabilities & media_file_format::B_KNOWS_ENCODED_VIDEO) {
			fOutputFileType->AddOption(mff.pretty_name, mff.family);
			if (firstFound) {
				fOutputFileType->MenuField()->Menu()->ItemAt(0)->SetMarked(true);
				firstFound = false;
			}
		}	
	}
	
	fWholeScreen->SetValue(B_CONTROL_ON);
	
	UpdateSettings();
	
	fController->SetCaptureArea(BScreen(Window()).Frame());
	fController->SetMediaFormatFamily(FormatFamily());
	fController->SetOutputFileName(fFileName->Text());
}