gstfilesrc源.doc

上传人:人*** 文档编号:546098980 上传时间:2022-10-02 格式:DOC 页数:28 大小:80KB
返回 下载 相关 举报
gstfilesrc源.doc_第1页
第1页 / 共28页
gstfilesrc源.doc_第2页
第2页 / 共28页
gstfilesrc源.doc_第3页
第3页 / 共28页
gstfilesrc源.doc_第4页
第4页 / 共28页
gstfilesrc源.doc_第5页
第5页 / 共28页
点击查看更多>>
资源描述

《gstfilesrc源.doc》由会员分享,可在线阅读,更多相关《gstfilesrc源.doc(28页珍藏版)》请在金锄头文库上搜索。

1、/* GStreamer * Copyright (C) 1999,2000 Erik Walthinsen * 2000,2005 Wim Taymans * * gstfilesrc.c: * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2

2、of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more det

3、ails. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */* * SECTION:element-filesrc * see_also: #GstFileSrc * * Read data from a

4、file in the local file system. */#ifdef HAVE_CONFIG_H# include config.h#endif#include #include gstfilesrc.h#include #include #ifdef G_OS_WIN32#include /* lseek, open, close, read */* On win32, stat* default to 32 bit; we need the 64-bit * variants, so explicitly define it that way. */#define stat _s

5、tat64#define fstat _fstat64#undef lseek#define lseek _lseeki64#undef off_t#define off_t guint64/* Prevent stat.h from defining the stat* functions as * _stat*, since were explicitly overriding that */#undef _INC_STAT_INL#endif#include #include #ifdef HAVE_UNISTD_H# include #endif#ifdef HAVE_MMAP# in

6、clude #endif#include #include #include ././gst/gst-i18n-lib.hstatic GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE (src, GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY);/* FIXME we should be using glib for this */#ifndef S_ISREG#define S_ISREG(mode) (mode)&_S_IFREG)#endif#ifndef S_ISDI

7、R#define S_ISDIR(mode) (mode)&_S_IFDIR)#endif#ifndef S_ISSOCK#define S_ISSOCK(x) (0)#endif#ifndef O_BINARY#define O_BINARY (0)#endif/* Copy of glibs g_open due to win32 libc/cross-DLL brokenness: we cant * use the file descriptor opened in glib (and returned from this function) * in this library, as

8、 they may have unrelated C runtimes. */intgst_open (const gchar * filename, int flags, int mode)#ifdef G_OS_WIN32 wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); int retval; int save_errno; if (wfilename = NULL) errno = EINVAL; return -1; retval = _wopen (wfilename, flags, mod

9、e); save_errno = errno; g_free (wfilename); errno = save_errno; return retval;#else return open (filename, flags, mode);#endif/* * GStreamer Default File Source * Theory of Operation * * Update: see GstFileSrc:use-mmap property documentation below * for why use of mmap() is disabled by default. * *

10、This source uses mmap(2) to efficiently load data from a file. * To do this without seriously polluting the applications memory * space, it must do so in smaller chunks, say 1-4MB at a time. * Buffers are then subdivided from these mmapd chunks, to directly * make use of the mmap. * * To handle refc

11、ounting so that the mmap can be freed at the appropriate * time, a buffer will be created for each mmapd region, and all new * buffers will be sub-buffers of this top-level buffer. As they are * freed, the refcount goes down on the mmapd buffer and its free() * function is called, which will call mu

12、nmap(2) on itself. * * If a buffer happens to cross the boundaries of an mmapd region, we * have to decide whether its more efficient to copy the data into a * new buffer, or mmap() just that buffer. There will have to be a * breakpoint size to determine which will be done. The mmap() size * has a l

13、ot to do with this as well, because you end up in double- * jeopardy: the larger the outgoing buffer, the more data to copy when * it overlaps, *and* the more frequently youll have buffers that *do* * overlap. * * Seeking is another tricky aspect to do efficiently. The initial * implementation of th

14、is source wont make use of these features, however. * The issue is that if an application seeks backwards in a file, *and* * that region of the file is covered by an mmap that hasnt been fully * deallocated, we really should re-use it. But keeping track of these * regions is tricky because we have to lock the structure that holds * them. We need to settle on a locking primitive (GMutex seems to be * a really good option.), then we can do that. */GST_DEBUG_CATEGORY_S

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号