Low framerate while playing streaming content

 

来自mail list

 

 

Low framerate while playing streaming content


  • SubjectLow framerate while playing streaming content
  • From: "Marcin Sokalski" <email@hidden>
  • Date: Thu, 19 Jun 2008 18:00:01 +0200
  • Delivered-to: email@hidden
  • Delivered-to: email@hidden

Hi,

I need to play streaming content (on Windows).
For tests i use Darwin Streaming Server 555.

Unfortunately I've encountered serious problem:
if the stream is >300kbit/s my player displays only every second
frame,
but playing same file directly from file works just fine.

Problem is not related to CPU usage (currently 1%),
and is not related to streaming server.

Quicktime Player plays the stream perfectly.
VLC player also!

I'm lost, anyone can help?

Marcin Sokalski
ATSI SA

email@hidden


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Below full source code. (no MovieControl, offscreen GWorld,
simple blitting to screen on MovieDrawingCompleteProc callback)


// qttest.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "qttest.h"

#include "QTML.h"
#include "Movies.h"
#include "ImageCompression.h"
#include "MacErrors.h"

#pragma comment(lib,"QTMLClient.lib")


void UpdateMovieGWorld(Movie m)
{
CGrafPtr port;
GDHandle dev;
GetMovieGWorld(m,&port,&dev);

Rect box;
GetMovieNaturalBoundsRect(m,&box);

MacOffsetRect (&box, -box.left, -box.top);
SetMovieBox (m, &box);

int width=box.right;
int height=box.bottom;

GWorldPtr movieGWorld;
void* pixels=malloc(width*height*4);

NewGWorldFromPtr(&movieGWorld,k32BGRAPixelFormat,&box,0,0,0,(Ptr)pixels,width*4);

SetMovieGWorld (m, (CGrafPtr)movieGWorld, nil);

if (port && !dev)
{
pixels=port->portPixMap[0]->baseAddr;
DisposeGWorld(port);
free(pixels);
}
}

void MyMoviePrePrerollCompleteProc(Movie theMovie, OSErr prerollErr,
void *refcon)
{
Fixed rate=GetMoviePreferredRate(theMovie);
PrerollMovie(theMovie,0,rate);
SetMovieRate(theMovie,rate);
StartMovie(theMovie);
}

OSErr MyMovieDrawingCompleteProc(Movie theMovie, long refCon)
{
// measure fps here
static int bias=0;
bias++;
if (bias==10)
bias=0;

if (!bias)
{
static DWORD t0=GetTickCount();

DWORD t1=GetTickCount();

DWORD t=t1-t0;
t0=t1;

if (!t)
t=-1;

int fps=10000/t;

wchar_t dbg[64];

swprintf_s(dbg,L"fps:%d/n",fps);
OutputDebugString(dbg);
}

CGrafPtr port;
GDHandle dev;
GetMovieGWorld(theMovie,&port,&dev);

char* pixels=port->portPixMap[0]->baseAddr;
int pixels_width=port->portPixMap[0]->bounds.right;
int pixels_height=port->portPixMap[0]->bounds.bottom;

BITMAPINFOHEADER bih;

bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biWidth = pixels_width;
bih.biHeight = -1 * pixels_height; // top down dib
bih.biPlanes = 1;
bih.biBitCount = 32;
bih.biCompression = BI_RGB;
bih.biSizeImage = 0;
bih.biXPelsPerMeter = 0;
bih.biYPelsPerMeter = 0;
bih.biClrUsed = 0;
bih.biClrImportant = 0;

HDC dc=GetDC(0);
SetDIBitsToDevice(dc,0,0,pixels_width,pixels_height,0,0,0,pixels_height,pixels,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
ReleaseDC(0,dc);

return noErr;
}


bool LoadMovieFromPath(Movie* m, const char* thePath)
{
char fullpath[255];
strcpy(fullpath,thePath);
c2pstr(fullpath);

short theFile = 0;
FSSpec sfFile;

FSMakeFSSpec (0, 0L, (ConstStr255Param)fullpath, &sfFile);

int err=OpenMovieFile (&sfFile, &theFile, fsRdPerm);
if (err!=noErr)
return false;

err=NewMovieFromFile (m, theFile, nil, nil, newMovieActive,
nil);

CloseMovieFile (theFile);

if (err!=noErr)
return false;

UpdateMovieGWorld(*m);

MyMoviePrePrerollCompleteProc(*m,0,0);

return true;
}

bool LoadMovieFromURL(Movie* m, const char* theURL)
{
Handle myHandle = NULL;
Size mySize = 0;

// get the size of the specified URL
mySize = (Size)strlen(theURL) + 1;
if (mySize == 0)
return false;

// allocate a new handle
myHandle = NewHandleClear(mySize);
if (myHandle == NULL)
return false;

// copy the URL into the handle
BlockMove(theURL, *myHandle, mySize);

// instantiate a movie from the specified URL
OSErr err=
NewMovieFromDataRef(m, newMovieActive | newMovieAsyncOK,
NULL, myHandle, URLDataHandlerSubType);

DisposeHandle(myHandle);

if (err!=noErr)
{
return false;
}

UpdateMovieGWorld(*m);

SetMovieDrawingCompleteProc(*m, movieDrawingCallWhenChanged,
MyMovieDrawingCompleteProc, 0 /*refCon*/);

SetMoviePlayHints(*m, hintsAllowDynamicResize,
hintsAllowDynamicResize);

err=PrePrerollMovie(*m, 0, GetMoviePreferredRate(*m),
NewMoviePrePrerollCompleteProc(MyMoviePrePrerollCompleteProc),
(void *)0L);

return true;
}


int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// init qt
OSErr err;
err = InitializeQTML(kInitializeQTMLUseGDIFlag);

err = EnterMovies ();

// check ver
long version;
OSErr result;

result = Gestalt(gestaltQuickTime,&version);
if ((result == noErr) && (version >= 0x05020000))
{
/* we have version 5.0.2 or later */
}
else
return 0;

// get the movie from url or file path
Movie theMovie;

const char* url="rtsp://10.48.2.84/wallie";;
const char* path="C://Program Files//Darwin Streaming
Server//Movies//WALLE_~3.MOV";
//if (!LoadMovieFromPath(&theMovie,path))
if (!LoadMovieFromURL(&theMovie,url))
return 0;

SetMovieDrawingCompleteProc(theMovie,
movieDrawingCallWhenChanged, MyMovieDrawingCompleteProc, 0
/*refCon*/);

Rect box;
GetMovieNaturalBoundsRect(theMovie,&box);

DWORD bias=GetTickCount();

while ( !IsMovieDone(theMovie) )
{
// Handle resize and update events...
Rect r;
GetMovieNaturalBoundsRect(theMovie,&r);
if (r.right!=box.right || r.bottom!=box.bottom)
{
box.right=r.right;
box.bottom=r.bottom;
UpdateMovieGWorld(theMovie);
}

// internal QT message pump, YUCK!
MSG msg;
while (PeekMessage(&msg,0,0,0,PM_REMOVE))
{
if (msg.hwnd)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
MoviesTask (theMovie, 5000);
Sleep(1);
}

CGrafPtr port;
GDHandle dev;
GetMovieGWorld(theMovie,&port,&dev);
DisposeGWorld(port);

DisposeMovie (theMovie);

ExitMovies();
TerminateQTML();

return 0;
}


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
End of source code




CONFIDENTIALITY NOTICE
This message is intended exclusively for the individual or entity to which it is addressed. This communication may contain information that is proprietary, privileged, confidential or otherwise legally exempt from disclosure. If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please delete all copies of this message and notify the sender immediately by return mail or fax ATSI S.A.(+4812) 285 36 04.
Any email attachment may contain software viruses which could damage your own computer system. Whilst reasonable precaution has been taken to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should therefore carry out your own virus checks before opening any attachments.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值