資源簡介
從ffmpeg庫中提取出來的組播發送和接收代碼,經過測試可以使用。

代碼片段和文件信息
/**
?*?@file
?*?UDP?protocol
?*/
#define?_BSD_SOURCE?????/*?Needed?for?using?struct?ip_mreq?with?recent?glibc?*/
/*
#include?“avformat.h“
#include?“avio_internal.h“
#include?“libavutil/parseutils.h“
#include?“libavutil/fifo.h“
#include?“libavutil/intreadwrite.h“
#include?“libavutil/avstring.h“
#include?“libavutil/opt.h“
#include?“libavutil/log.h“
#include?“libavutil/time.h“
#include?“internal.h“
#include?“os_support.h“
#include?“url.h“
*/
#include?
#include?
#include?
#include?
#include?
#include?
???
#include?“udp.h“
#include?
#define?AVIO_FLAG_READ??1??????????????????????????????????????/**#define?AVIO_FLAG_WRITE?2??????????????????????????????????????/**#define?AVIO_FLAG_READ_WRITE?(AVIO_FLAG_READ|AVIO_FLAG_WRITE)??/**
/**
?*?Use?non-blocking?mode.
?*?If?this?flag?is?set?operations?on?the?context?will?return
?*?AVERROR(EAGAIN)?if?they?can?not?be?performed?immediately.
?*?If?this?flag?is?not?set?operations?on?the?context?will?never?return
?*?AVERROR(EAGAIN).
?*?Note?that?this?flag?does?not?affect?the?opening/connecting?of?the
?*?context.?Connecting?a?protocol?will?always?block?if?necessary?(e.g.?on
?*?network?protocols)?but?never?hang?(e.g.?on?busy?devices).
?*?Warning:?non-blocking?protocols?is?work-in-progress;?this?flag?may?be
?*?silently?ignored.
?*/
#define?AVIO_FLAG_NONBLOCK?8
/**
?*?Use?direct?mode.
?*?avio_read?and?avio_write?should?if?possible?be?satisfied?directly
?*?instead?of?going?through?a?buffer?and?avio_seek?will?always
?*?call?the?underlying?seek?function?directly.
?*/
#define?AVIO_FLAG_DIRECT?0x8000
#ifndef?HAVE_PTHREAD_CANCEL
#define?HAVE_PTHREAD_CANCEL?0
#endif
#ifndef?IPV6_ADD_MEMBERSHIP
#define?IPV6_ADD_MEMBERSHIP??IPV6_JOIN_GROUP
#define?IPV6_DROP_MEMBERSHIP?IPV6_LEAVE_GROUP
#endif
/*?error?handling?*/
#if?EDOM?>?0
#define?AVERROR(e)?(-(e))???///#define?AVUNERROR(e)?(-(e))?///#else
/*?Some?platforms?have?E*?and?errno?already?negated.?*/
#define?AVERROR(e)?(e)
#define?AVUNERROR(e)?(e)
#endif
#include?
static?int?ff_network_wait_fd(int?fd?int?write)
{
????int?ev?=?write???POLLOUT?:?POLLIN;
????struct?pollfd?p?=?{?.fd?=?fd?.events?=?ev?.revents?=?0?};
????int?ret;
????ret?=?poll(&p?1?100);
return?ret;
????//return?ret?0???ff_neterrno()?:?p.revents?&?(ev?|?POLLERR?|?POLLHUP)???0?:?AVERROR(EAGAIN);
}
//poll?返回?=0?代表超時
//poll?返回?>0?代表有ret個套接字有數據可以處理
//poll?返回?<0?代表出錯
//RETURN?VALUE
//???????On?success?a?positive?number?is?returned;?this?is?the?number?of?structures?which?have?non-zero?revents??fields
//???????(in?other?words?those?descriptors?with?events?or?errors?reported).??A?value?of?0?indicates?that?the?call?timed
//???????out?and?no?file?descriptors?were?ready.?On?error?-1?is?returned?and?errno?is?set?ap
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5513??2015-12-01?13:21??udp.h
?????文件???????29117??2015-12-02?17:16??udp.c
評論
共有 條評論