Exemple #1
0
InfoView::InfoView(Controller* controller)
	:
	BView("Info", B_WILL_DRAW),
	fController(controller)
{
	Settings settings;
	BRect sourceArea = settings.CaptureArea();
	BRect targetRect = settings.TargetRect();
	float scale = settings.Scale();
	
	SetLayout(new BGroupLayout(B_VERTICAL));
	BView* layoutView = BLayoutBuilder::Group<>()
		.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
		.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
			B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
			.Add(fSourceSize = new BStringView("source size",
				GetSourceRectString(sourceArea)))
			.Add(fClipSize = new BStringView("clip size",
				GetTargetRectString(targetRect)))
			.Add(fScale = new BStringView("clip scale",
				GetScaleString(scale)))
			.Add(fFormat = new BStringView("format", ""))
			.Add(fCodec = new BStringView("codec", ""))
			.Add(fCaptureFrameDelay = new BStringView("capturedelay",
				GetDelayString(settings.CaptureFrameDelay())))
		.End()
		.View();
	AddChild(layoutView);
}
Exemple #2
0
int32
Controller::CaptureThread()
{
	Settings settings;
	BScreen screen;
	BRect bounds = settings.CaptureArea();
	bigtime_t captureDelay = (bigtime_t)settings.CaptureFrameDelay() * 1000;
	
	// TODO: Validate captureDelay with some limits
	
	_DumpSettings();
	_TestWaitForRetrace();
	
	const int32 windowBorder = settings.WindowFrameBorderSize();
	int32 token = GetWindowTokenForFrame(bounds, windowBorder);
	bigtime_t waitTime = 0;
	status_t error = B_ERROR;
	while (!fKillThread) {
		if (!fPaused) {		
			if (token != -1) {
				BRect windowBounds = GetWindowFrameForToken(token, windowBorder);
				if (windowBounds.IsValid())
					bounds.OffsetTo(windowBounds.LeftTop());
			}
				
			_WaitForRetrace(captureDelay); // Wait for Vsync
			BBitmap *bitmap = new BBitmap(bounds, screen.ColorSpace());
			error = ReadBitmap(bitmap, true, bounds);
			bigtime_t currentTime = system_time();
			// Takes ownership of the bitmap
	    	if (error == B_OK && fFileList->AddItem(bitmap, currentTime))
				atomic_add(&fNumFrames, 1);
			else {
				delete bitmap;
				break;
			}
		} else
			snooze(500000);
	}
	
	fCaptureThread = -1;
	fKillThread = true;
	
	if (error != B_OK) {
		BMessage message(kMsgControllerCaptureStopped);
		message.AddInt32("status", (int32)error);
		SendNotices(kMsgControllerCaptureStopped, &message);
		
		delete fFileList;
		fFileList = NULL;
	}
		
	return B_OK;
}
void 
OutputView::BuildCodecMenu(const media_format_family &family)
{
	Settings settings;
	BRect rect = settings.CaptureArea();//ClipFrame();
	rect.right++;
	rect.bottom++;
		
	GetCodecsForFamily(family, (const int32 &)rect.IntegerWidth(),
		(const int32 &)rect.IntegerHeight(), fCodecMenu->Menu(), fFormat);
		
	// Make the app object the menu's message target
	fCodecMenu->Menu()->SetTargetForItems(this);
}
Exemple #4
0
Controller::Controller()
	:
	BLooper("Controller"),
	fCaptureThread(-1),
	fNumFrames(0),
	fKillThread(true),
	fPaused(false),
	fDirectWindowAvailable(false),
	fEncoder(NULL),
	fEncoderThread(-1),
	fFileList(NULL),
	fCodecList(NULL)
{
	memset(&fDirectInfo, 0, sizeof(fDirectInfo));
	
	fEncoder = new MovieEncoder;

	Settings settings;	
	BString name = settings.OutputFileName();
	fEncoder->SetOutputFile(name.String());

	BRect rect = settings.CaptureArea();
	SetCaptureArea(rect);
	
	BString fileFormatName;
	settings.GetOutputFileFormat(fileFormatName);
	
	media_file_format fileFormat;
	if (!get_media_file_format(fileFormatName.String(), &fileFormat)) {
		if (!get_media_file_format(NULL, &fileFormat))
			throw "Unable to find a suitable media_file_format!";
	}		
	
	SetMediaFileFormat(fileFormat);
	
	BString codecName;
	settings.GetOutputCodec(codecName);
	
	if (codecName != "")
		SetMediaCodec(codecName);
	else
		SetMediaCodec(fCodecList->ItemAt(0)->pretty_name);
	Run();
}