Esempio n. 1
0
void
MediaView::Draw(
	BRect	updateRect)
{
	if ((fBitmap != NULL) && !fUsingOverlay)
		DrawBitmap(fBitmap, VideoBounds());
}
Esempio n. 2
0
status_t
NodeManager::FormatChanged(BRect videoBounds, float videoFrameRate,
	color_space preferredVideoFormat, float audioFrameRate,
	uint32 audioChannels, uint32 enabledNodes, bool useOverlays, bool force)
{
	TRACE("NodeManager::FormatChanged()\n");

	if (!force && videoBounds == VideoBounds()
		&& videoFrameRate == FramesPerSecond()) {
		TRACE("   -> reusing existing nodes\n");
		// TODO: if enabledNodes would indicate that audio or video
		// is no longer needed, or, worse yet, suddenly needed when
		// it wasn't before, then we should not return here!
		PlaybackManager::Init(videoFrameRate, false, LoopMode(),
			IsLoopingEnabled(), Speed(), MODE_PLAYING_PAUSED_FORWARD,
			CurrentFrame());
		return B_OK;
	}

	_StopNodes();
	_TearDownNodes();

	PlaybackManager::Init(videoFrameRate, true, LoopMode(), IsLoopingEnabled(),
		Speed(), MODE_PLAYING_PAUSED_FORWARD, CurrentFrame());

	SetVideoBounds(videoBounds);

	status_t ret = _SetUpNodes(preferredVideoFormat, enabledNodes,
		useOverlays, audioFrameRate, audioChannels);
	if (ret == B_OK)
		_StartNodes();
	else
		fprintf(stderr, "unable to setup nodes: %s\n", strerror(ret));

	return ret;
}
Esempio n. 3
0
status_t
MediaView::SetVideoTrack(
	BDataIO       *data,
	BMediaTrack		*track,
	media_format	*format)
{
	if (fVideoTrack != NULL)
		// is it possible to have multiple video tracks?
		return (B_ERROR);

	fVideoTrack = track;

	BRect bitmapBounds(0.0, 
					   0.0, 
					   format->u.encoded_video.output.display.line_width - 1.0,
					   format->u.encoded_video.output.display.line_count - 1.0);

	fBitmap = new BBitmap(bitmapBounds,B_BITMAP_WILL_OVERLAY|B_BITMAP_RESERVE_OVERLAY_CHANNEL,B_YCbCr422);
	fUsingOverlay = true;
	if (fBitmap->InitCheck() != B_OK) {
		delete fBitmap;
		fBitmap = new BBitmap(bitmapBounds, fBitmapDepth);
		fUsingOverlay = false;
	};

	/* loop, asking the track for a format we can deal with */
	for(;;) {
		media_format mf, old_mf;

		BuildMediaFormat(fBitmap, &mf);

		old_mf = mf;
		fVideoTrack->DecodedFormat(&mf);
		if (old_mf.u.raw_video.display.format == mf.u.raw_video.display.format) {
			break;
		}

		printf("wanted cspace 0x%x, but it was reset to 0x%x\n",
			   fBitmapDepth, mf.u.raw_video.display.format);
		
		fBitmapDepth = mf.u.raw_video.display.format;
		delete fBitmap;
		fUsingOverlay = false;
		fBitmap = new BBitmap(bitmapBounds, fBitmapDepth);
	}

	media_header mh;
	bigtime_t time = fCurTime;	
	fVideoTrack->SeekToTime(&time);

	int64 dummyNumFrames = 0;
	fVideoTrack->ReadFrames((char *)fBitmap->Bits(), &dummyNumFrames, &mh);

	time = fCurTime;
	fVideoTrack->SeekToTime(&time);	

	if (fUsingOverlay) {
		overlay_restrictions r;
		fBitmap->GetOverlayRestrictions(&r);
	
		printf("Overlay limits:\n");
		printf("  Src horiz alignment  : %08x\n",r.source.horizontal_alignment);
		printf("  Src vert alignment   : %08x\n",r.source.vertical_alignment);
		printf("  Src width alignment  : %08x\n",r.source.width_alignment);
		printf("  Src height alignment : %08x\n",r.source.height_alignment);
		printf("  Src min/max          : (%d,%d)/(%d,%d)\n",r.source.min_width,r.source.min_height,
															r.source.max_width,r.source.max_height);
		printf("  Dst horiz alignment  : %08x\n",r.destination.horizontal_alignment);
		printf("  Dst vert alignment   : %08x\n",r.destination.vertical_alignment);
		printf("  Dst width alignment  : %08x\n",r.destination.width_alignment);
		printf("  Dst height alignment : %08x\n",r.destination.height_alignment);
		printf("  Dst min/max          : (%d,%d)/(%d,%d)\n",r.destination.min_width,r.destination.min_height,
															r.destination.max_width,r.destination.max_height);
		printf("  Min/max scaling      : (%f,%f)/(%f,%f)\n",r.min_width_scale,r.min_height_scale,
															r.max_width_scale,r.max_height_scale);
		rgb_color key;
		SetViewOverlay(fBitmap,bitmapBounds,VideoBounds(),&key,B_FOLLOW_ALL,
			B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL);
		SetViewColor(key);
	};

	return (B_NO_ERROR);
}