• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavdevice/dshow_common.c

Go to the documentation of this file.
00001 /*
00002  * Directshow capture interface
00003  * Copyright (c) 2010 Ramiro Polla
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #include "dshow.h"
00023 
00024 long ff_copy_dshow_media_type(AM_MEDIA_TYPE *dst, const AM_MEDIA_TYPE *src)
00025 {
00026     uint8_t *pbFormat = NULL;
00027 
00028     if (src->cbFormat) {
00029         pbFormat = CoTaskMemAlloc(src->cbFormat);
00030         if (!pbFormat)
00031             return E_OUTOFMEMORY;
00032         memcpy(pbFormat, src->pbFormat, src->cbFormat);
00033     }
00034 
00035     *dst = *src;
00036     dst->pUnk = NULL;
00037     dst->pbFormat = pbFormat;
00038 
00039     return S_OK;
00040 }
00041 
00042 void ff_printGUID(const GUID *g)
00043 {
00044 #if DSHOWDEBUG
00045     const uint32_t *d = (const uint32_t *) &g->Data1;
00046     const uint16_t *w = (const uint16_t *) &g->Data2;
00047     const uint8_t  *c = (const uint8_t  *) &g->Data4;
00048 
00049     dshowdebug("0x%08x 0x%04x 0x%04x %02x%02x%02x%02x%02x%02x%02x%02x",
00050                d[0], w[0], w[1],
00051                c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
00052 #endif
00053 }
00054 
00055 static const char *dshow_context_to_name(void *ptr)
00056 {
00057     return "dshow";
00058 }
00059 static const AVClass ff_dshow_context_class = { "DirectShow", dshow_context_to_name };
00060 const AVClass *ff_dshow_context_class_ptr = &ff_dshow_context_class;
00061 
00062 #define dstruct(pctx, sname, var, type) \
00063     dshowdebug("      "#var":\t%"type"\n", sname->var)
00064 
00065 #if DSHOWDEBUG
00066 static void dump_bih(void *s, BITMAPINFOHEADER *bih)
00067 {
00068     dshowdebug("      BITMAPINFOHEADER\n");
00069     dstruct(s, bih, biSize, "lu");
00070     dstruct(s, bih, biWidth, "ld");
00071     dstruct(s, bih, biHeight, "ld");
00072     dstruct(s, bih, biPlanes, "d");
00073     dstruct(s, bih, biBitCount, "d");
00074     dstruct(s, bih, biCompression, "lu");
00075     dshowdebug("      biCompression:\t\"%.4s\"\n",
00076                    (char*) &bih->biCompression);
00077     dstruct(s, bih, biSizeImage, "lu");
00078     dstruct(s, bih, biXPelsPerMeter, "lu");
00079     dstruct(s, bih, biYPelsPerMeter, "lu");
00080     dstruct(s, bih, biClrUsed, "lu");
00081     dstruct(s, bih, biClrImportant, "lu");
00082 }
00083 #endif
00084 
00085 void ff_print_AM_MEDIA_TYPE(const AM_MEDIA_TYPE *type)
00086 {
00087 #if DSHOWDEBUG
00088     dshowdebug("    majortype\t");
00089     ff_printGUID(&type->majortype);
00090     dshowdebug("\n");
00091     dshowdebug("    subtype\t");
00092     ff_printGUID(&type->subtype);
00093     dshowdebug("\n");
00094     dshowdebug("    bFixedSizeSamples\t%d\n", type->bFixedSizeSamples);
00095     dshowdebug("    bTemporalCompression\t%d\n", type->bTemporalCompression);
00096     dshowdebug("    lSampleSize\t%lu\n", type->lSampleSize);
00097     dshowdebug("    formattype\t");
00098     ff_printGUID(&type->formattype);
00099     dshowdebug("\n");
00100     dshowdebug("    pUnk\t%p\n", type->pUnk);
00101     dshowdebug("    cbFormat\t%lu\n", type->cbFormat);
00102     dshowdebug("    pbFormat\t%p\n", type->pbFormat);
00103 
00104     if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo)) {
00105         VIDEOINFOHEADER *v = (void *) type->pbFormat;
00106         dshowdebug("      rcSource: left %ld top %ld right %ld bottom %ld\n",
00107                    v->rcSource.left, v->rcSource.top, v->rcSource.right, v->rcSource.bottom);
00108         dshowdebug("      rcTarget: left %ld top %ld right %ld bottom %ld\n",
00109                    v->rcTarget.left, v->rcTarget.top, v->rcTarget.right, v->rcTarget.bottom);
00110         dshowdebug("      dwBitRate: %lu\n", v->dwBitRate);
00111         dshowdebug("      dwBitErrorRate: %lu\n", v->dwBitErrorRate);
00112         dshowdebug("      AvgTimePerFrame: %"PRId64"\n", v->AvgTimePerFrame);
00113         dump_bih(NULL, &v->bmiHeader);
00114     } else if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo2)) {
00115         VIDEOINFOHEADER2 *v = (void *) type->pbFormat;
00116         dshowdebug("      rcSource: left %ld top %ld right %ld bottom %ld\n",
00117                    v->rcSource.left, v->rcSource.top, v->rcSource.right, v->rcSource.bottom);
00118         dshowdebug("      rcTarget: left %ld top %ld right %ld bottom %ld\n",
00119                    v->rcTarget.left, v->rcTarget.top, v->rcTarget.right, v->rcTarget.bottom);
00120         dshowdebug("      dwBitRate: %lu\n", v->dwBitRate);
00121         dshowdebug("      dwBitErrorRate: %lu\n", v->dwBitErrorRate);
00122         dshowdebug("      AvgTimePerFrame: %"PRId64"\n", v->AvgTimePerFrame);
00123         dshowdebug("      dwInterlaceFlags: %lu\n", v->dwInterlaceFlags);
00124         dshowdebug("      dwCopyProtectFlags: %lu\n", v->dwCopyProtectFlags);
00125         dshowdebug("      dwPictAspectRatioX: %lu\n", v->dwPictAspectRatioX);
00126         dshowdebug("      dwPictAspectRatioY: %lu\n", v->dwPictAspectRatioY);
00127 //        dshowdebug("      dwReserved1: %lu\n", v->u.dwReserved1); /* mingw-w64 is buggy and doesn't name unnamed unions */
00128         dshowdebug("      dwReserved2: %lu\n", v->dwReserved2);
00129         dump_bih(NULL, &v->bmiHeader);
00130     } else if (IsEqualGUID(&type->formattype, &FORMAT_WaveFormatEx)) {
00131         WAVEFORMATEX *fx = (void *) type->pbFormat;
00132         dshowdebug("      wFormatTag: %u\n", fx->wFormatTag);
00133         dshowdebug("      nChannels: %u\n", fx->nChannels);
00134         dshowdebug("      nSamplesPerSec: %lu\n", fx->nSamplesPerSec);
00135         dshowdebug("      nAvgBytesPerSec: %lu\n", fx->nAvgBytesPerSec);
00136         dshowdebug("      nBlockAlign: %u\n", fx->nBlockAlign);
00137         dshowdebug("      wBitsPerSample: %u\n", fx->wBitsPerSample);
00138         dshowdebug("      cbSize: %u\n", fx->cbSize);
00139     }
00140 #endif
00141 }

Generated on Fri Feb 22 2013 07:24:30 for FFmpeg by  doxygen 1.7.1