Hello,
Måns Rullgård wrote:
> Ramiro Polla <ramiro lisha.ufsc.br> writes:
>
>>>>>> struct vfw_ctx {
>>>>>> HWND hwnd;
>>>>>> int grabbed;
>>>>>> AVPacket *pkt;
>>>>>> };
>>>>>>
>>>>>> static int vfw_pixfmt( DWORD
biCompression )
>>>>> Do we really have to use those dreadful
windows typedefs and naming
>>>>> conventions?
>>>> I find it best when writing an interface to
an API that has
>>>> documentation, the same way you follow
variable names from specs.
>>> This function isn't part of any API.
>> DWORD biCompression is part of the documentation.
>
> As part of the BITMAPINFOHEADER struct, yes. That
function of yours
> is certainly not in any MS API.
So, what do you suggest?
DWORD -> uint32_t which is possibly incorrect
biCompression -> someothername
>>>> ctx->hwnd = capCreateCaptureWindow(
NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0 );
>>>> if( !ctx->hwnd ) {
>>>> av_log( s, AV_LOG_ERROR,
"Could not create capture window.n" );
>>>> return AVERROR_IO;
>>>> }
>> I don't know how this can fail. Left as is.
>
> I can imagine it might run out of memory or whatever
other limited
> resources it needs. I'm sure there's some upper limit
for the number
> of windows.
>
>>>> /* If atoi fails, devnum==0 and the
default device is used */
>>>> devnum = atoi( s->filename );
>>>>
>>>> ret = SendMessage( ctx->hwnd,
WM_CAP_DRIVER_CONNECT, devnum, 0 );
>>>> if( !ret ) {
>>>> av_log( s, AV_LOG_ERROR,
"Could not connect to device.n" );
>>>> return AVERROR_IO;
>>>> }
>>> I'm not sure AVERROR_IO is the proper error
code for those failures.
>> Other grab devices mostly return EIO.
>
> EIO is appropriate when an attempt to perform I/O
failed. IMHO,
> device setup doesn't quite fit that label.
Well, that's what x11grab uses. Can you suggest any other
error?
>> /*
>> * VFW capture interface
>> * Copyright (c) 2006-2008 Ramiro Polla.
>> *
>> * This file is part of FFmpeg.
>> *
>> * FFmpeg is free software; you can redistribute it
and/or
>> * modify it under the terms of the GNU Lesser
General Public
>> * License as published by the Free Software
Foundation; either
>> * version 2.1 of the License, or (at your option)
any later version.
>> *
>> * FFmpeg is distributed in the hope that it will
be useful,
>> * but WITHOUT ANY WARRANTY; without even the
implied warranty of
>> * MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU
>> * Lesser General Public License for more details.
>> *
>> * You should have received a copy of the GNU
Lesser General Public
>> * License along with FFmpeg; if not, write to the
Free Software
>> * Foundation, Inc., 51 Franklin Street, Fifth
Floor, Boston, MA 02110-1301 USA
>> */
>>
>> #include "avformat.h"
>> #include <vfw.h>
>> #include <windows.h>
>>
>> /* Defines for VFW missing from MinGW.
>> * Remove this when MinGW incorporates them. */
>> #define WM_CAP_START (0x0400)
>> #define WM_CAP_SET_CALLBACK_FRAME (WM_CAP_START +
5)
>> #define WM_CAP_GET_USER_DATA (WM_CAP_START +
8)
>> #define WM_CAP_SET_USER_DATA (WM_CAP_START +
9)
>> #define WM_CAP_DRIVER_CONNECT (WM_CAP_START +
10)
>> #define WM_CAP_DRIVER_DISCONNECT (WM_CAP_START +
11)
>> #define WM_CAP_GRAB_FRAME (WM_CAP_START +
60)
>> #define WM_CAP_GET_VIDEOFORMAT (WM_CAP_START +
44)
>> #define WM_CAP_SET_PREVIEW (WM_CAP_START +
50)
>> #define WM_CAP_SET_OVERLAY (WM_CAP_START +
51)
>>
>> #define HWND_MESSAGE ((HWND)-3)
>>
>> #define BI_RGB 0
>>
>> typedef struct videohdr_tag {
>> LPBYTE lpData;
>> DWORD dwBufferLength;
>> DWORD dwBytesUsed;
>> DWORD dwTimeCaptured;
>> DWORD dwUser;
>> DWORD dwFlags;
>> DWORD_PTR dwReserved[4];
>> } VIDEOHDR, NEAR *PVIDEOHDR, FAR * LPVIDEOHDR;
>> /* End of missing MinGW defines */
>>
>> struct vfw_ctx {
>> HWND hwnd;
>> int grabbed;
>> AVPacket *pkt;
>> };
>>
>> static int vfw_pixfmt( AVFormatContext *s, DWORD
biCompression )
>
> This function could return enum PixelFormat.
Done.
>> {
>> switch( biCompression ) {
>> case MKTAG( 'Y', 'U', 'Y', '2' ):
>> return PIX_FMT_YUYV422;
>> case BI_RGB:
>> return PIX_FMT_BGR24;
>> }
>> av_log( s, AV_LOG_ERROR, "Unknown
compression type."
>> "Please report
debug information.n" );
>
> Printing the value of the unknown format could be
useful.
It is printed if you use verbose. Now the error msg (moved
out of this
function) prints:
"Please report verbose (-v 99) debug
information."
Ramiro Polla
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
|