Merge remote-tracking branch 'qatar/master'

* qatar/master:
  libopenjpeg: introduce encoding support
  libopenjpeg: rename decoder source file.
  RTMPTS protocol support
  RTMPS protocol support
  avconv: print an error message when demuxing fails.
  tscc2: DCT output should not be clipped
  rtmp: Rename rtmphttp to ffrtmphttp

Conflicts:
	Changelog
	configure
	doc/general.texi
	libavcodec/libopenjpegenc.c
	libavcodec/version.h
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/59/head
Michael Niedermayer 13 years ago
commit 56ae5926f7
  1. 2
      Changelog
  2. 12
      configure
  3. 5
      doc/general.texi
  4. 15
      doc/protocols.texi
  5. 5
      ffmpeg.c
  6. 46
      libavcodec/libopenjpegenc.c
  7. 2
      libavcodec/tscc2.c
  8. 2
      libavcodec/version.h
  9. 4
      libavformat/Makefile
  10. 4
      libavformat/allformats.c
  11. 1
      libavformat/rtmp.h
  12. 35
      libavformat/rtmphttp.c
  13. 52
      libavformat/rtmpproto.c
  14. 4
      libavformat/version.h

@ -19,6 +19,8 @@ version next:
- TechSmith Screen Codec 2 decoder
- AAC encoding via libfdk-aac
- Microsoft Expression Encoder Screen decoder
- RTMPS protocol support
- RTMPTS protocol support
- showwaves filter
- LucasArts SMUSH playback support
- SAMI demuxer and decoder

12
configure vendored

@ -190,7 +190,7 @@ External library support:
--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
--enable-libopencv enable video filtering via libopencv [no]
--enable-libopenjpeg enable JPEG 2000 encoding/decoding via OpenJPEG [no]
--enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
--enable-libpulse enable Pulseaudio input via libpulse [no]
--enable-librtmp enable RTMP[E] support via librtmp [no]
--enable-libschroedinger enable Dirac support via libschroedinger [no]
@ -1712,6 +1712,8 @@ x11_grab_device_indev_deps="x11grab XShmCreateImage"
# protocols
bluray_protocol_deps="libbluray"
ffrtmphttp_protocol_deps="!librtmp_protocol"
ffrtmphttp_protocol_select="http_protocol"
gopher_protocol_deps="network"
httpproxy_protocol_deps="network"
httpproxy_protocol_select="tcp_protocol"
@ -1727,10 +1729,12 @@ mmsh_protocol_select="http_protocol"
mmst_protocol_deps="network"
rtmp_protocol_deps="!librtmp_protocol"
rtmp_protocol_select="tcp_protocol"
rtmphttp_protocol_deps="!librtmp_protocol"
rtmphttp_protocol_select="http_protocol"
rtmps_protocol_deps="!librtmp_protocol"
rtmps_protocol_select="tls_protocol"
rtmpt_protocol_deps="!librtmp_protocol"
rtmpt_protocol_select="rtmphttp_protocol"
rtmpt_protocol_select="ffrtmphttp_protocol"
rtmpts_protocol_deps="!librtmp_protocol"
rtmpts_protocol_select="ffrtmphttp_protocol"
rtp_protocol_select="udp_protocol"
sctp_protocol_deps="network netinet_sctp_h"
tcp_protocol_deps="network"

@ -905,9 +905,10 @@ performance on systems without hardware floating point support).
@item pipe @tab X
@item RTMP @tab X
@item RTMPE @tab E
@item RTMPS @tab E
@item RTMPT @tab E
@item RTMPS @tab X
@item RTMPT @tab X
@item RTMPTE @tab E
@item RTMPTS @tab X
@item RTP @tab X
@item SCTP @tab X
@item TCP @tab X

@ -277,6 +277,13 @@ For example to read with @command{ffplay} a multimedia resource named
ffplay rtmp://myserver/vod/sample
@end example
@section rtmps
Real-Time Messaging Protocol over a secure SSL connection.
The Real-Time Messaging Protocol (RTMPS) is used for streaming
multimedia content across an encrypted connection.
@section rtmpt
Real-Time Messaging Protocol tunneled through HTTP.
@ -285,6 +292,14 @@ The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
for streaming multimedia content within HTTP requests to traverse
firewalls.
@section rtmpts
Real-Time Messaging Protocol tunneled through HTTPS.
The Real-Time Messaging Protocol tunneled through HTTPS (RTMPTS) is used
for streaming multimedia content within HTTPS requests to traverse
firewalls.
@section rtmp, rtmpe, rtmps, rtmpt, rtmpte
Real-Time Messaging Protocol and its variants supported through

@ -3645,6 +3645,11 @@ static int transcode(void)
continue;
}
if (ret < 0) {
if (ret != AVERROR_EOF) {
print_error(is->filename, ret);
if (exit_on_error)
exit_program(1);
}
input_files[file_index]->eof_reached = 1;
for (i = 0; i < input_files[file_index]->nb_streams; i++) {

@ -24,14 +24,15 @@
* JPEG 2000 encoder using libopenjpeg
*/
#define OPJ_STATIC
#include <openjpeg.h>
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "libavutil/intreadwrite.h"
#include "internal.h"
#define OPJ_STATIC
#include <openjpeg.h>
typedef struct {
AVClass *avclass;
@ -41,8 +42,8 @@ typedef struct {
opj_event_mgr_t event_mgr;
int format;
int profile;
int cinema_mode;
int prog_order;
int cinema_mode;
int numresolution;
int numlayers;
int disto_alloc;
@ -52,12 +53,17 @@ typedef struct {
static void error_callback(const char *msg, void *data)
{
av_log((AVCodecContext*)data, AV_LOG_ERROR, "libopenjpeg: %s\n", msg);
av_log(data, AV_LOG_ERROR, "%s\n", msg);
}
static void warning_callback(const char *msg, void *data)
{
av_log((AVCodecContext*)data, AV_LOG_WARNING, "libopenjpeg: %s\n", msg);
av_log(data, AV_LOG_WARNING, "%s\n", msg);
}
static void info_callback(const char *msg, void *data)
{
av_log(data, AV_LOG_DEBUG, "%s\n", msg);
}
static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *parameters)
@ -116,11 +122,13 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
color_space = CLRSPC_SYCC;
break;
default:
av_log(avctx, AV_LOG_ERROR, "The requested pixel format '%s' is not supported\n", av_get_pix_fmt_name(avctx->pix_fmt));
av_log(avctx, AV_LOG_ERROR,
"The requested pixel format '%s' is not supported\n",
av_get_pix_fmt_name(avctx->pix_fmt));
return NULL;
}
cmptparm = av_mallocz(numcomps * sizeof(opj_image_cmptparm_t));
cmptparm = av_mallocz(numcomps * sizeof(*cmptparm));
if (!cmptparm) {
av_log(avctx, AV_LOG_ERROR, "Not enough memory");
return NULL;
@ -143,8 +151,10 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
{
LibOpenJPEGContext *ctx = avctx->priv_data;
int err = AVERROR(ENOMEM);
opj_set_default_encoder_parameters(&ctx->enc_params);
ctx->enc_params.cp_rsiz = ctx->profile;
ctx->enc_params.mode = !!avctx->global_quality;
ctx->enc_params.cp_cinema = ctx->cinema_mode;
@ -164,26 +174,29 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
av_freep(&ctx->compress);
av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
return AVERROR(ENOMEM);
goto fail;
}
ctx->image = mj2_create_image(avctx, &ctx->enc_params);
if (!ctx->image) {
av_freep(&ctx->compress);
av_freep(&avctx->coded_frame);
av_log(avctx, AV_LOG_ERROR, "Error creating the mj2 image\n");
return AVERROR(EINVAL);
err = AVERROR(EINVAL);
goto fail;
}
memset(&ctx->event_mgr, 0, sizeof(opj_event_mgr_t));
ctx->event_mgr.info_handler = info_callback;
ctx->event_mgr.error_handler = error_callback;
ctx->event_mgr.warning_handler = warning_callback;
ctx->event_mgr.info_handler = NULL;
opj_set_event_mgr((opj_common_ptr)ctx->compress, &ctx->event_mgr, avctx);
return 0;
fail:
av_freep(&ctx->compress);
av_freep(&avctx->coded_frame);
return err;
}
static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
@ -373,13 +386,16 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
cpyresult = libopenjpeg_copy_unpacked16(avctx, frame, image);
break;
default:
av_log(avctx, AV_LOG_ERROR, "The frame's pixel format '%s' is not supported\n", av_get_pix_fmt_name(avctx->pix_fmt));
av_log(avctx, AV_LOG_ERROR,
"The frame's pixel format '%s' is not supported\n",
av_get_pix_fmt_name(avctx->pix_fmt));
return AVERROR(EINVAL);
break;
}
if (!cpyresult) {
av_log(avctx, AV_LOG_ERROR, "Could not copy the frame data to the internal image buffer\n");
av_log(avctx, AV_LOG_ERROR,
"Could not copy the frame data to the internal image buffer\n");
return -1;
}

@ -95,7 +95,7 @@ static av_cold int init_vlcs(TSCC2Context *c)
OP(d3, 5 * ((s0) - (s1) + (s2)) - 2 * (s3)); \
#define COL_OP(a, b) a = b
#define ROW_OP(a, b) a = av_clip_uint8((((b) + 0x20) >> 6) + 0x80)
#define ROW_OP(a, b) a = (((b) + 0x20) >> 6) + 0x80
static void tscc2_idct4_put(int *in, int q[3], uint8_t *dst, int stride)
{

@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 40
#define LIBAVCODEC_VERSION_MINOR 41
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

@ -373,6 +373,7 @@ OBJS-$(CONFIG_BLURAY_PROTOCOL) += bluray.o
OBJS-$(CONFIG_CACHE_PROTOCOL) += cache.o
OBJS-$(CONFIG_CONCAT_PROTOCOL) += concat.o
OBJS-$(CONFIG_CRYPTO_PROTOCOL) += crypto.o
OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL) += rtmphttp.o
OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
OBJS-$(CONFIG_GOPHER_PROTOCOL) += gopher.o
OBJS-$(CONFIG_HLS_PROTOCOL) += hlsproto.o
@ -384,8 +385,9 @@ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o
OBJS-$(CONFIG_MD5_PROTOCOL) += md5proto.o
OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPHTTP_PROTOCOL) += rtmphttp.o
OBJS-$(CONFIG_RTMPS_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPT_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTMPTS_PROTOCOL) += rtmpproto.o rtmppkt.o
OBJS-$(CONFIG_RTP_PROTOCOL) += rtpproto.o
OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
OBJS-$(CONFIG_TCP_PROTOCOL) += tcp.o

@ -272,6 +272,7 @@ void av_register_all(void)
REGISTER_PROTOCOL (CACHE, cache);
REGISTER_PROTOCOL (CONCAT, concat);
REGISTER_PROTOCOL (CRYPTO, crypto);
REGISTER_PROTOCOL (FFRTMPHTTP, ffrtmphttp);
REGISTER_PROTOCOL (FILE, file);
REGISTER_PROTOCOL (GOPHER, gopher);
REGISTER_PROTOCOL (HLS, hls);
@ -283,8 +284,9 @@ void av_register_all(void)
REGISTER_PROTOCOL (MD5, md5);
REGISTER_PROTOCOL (PIPE, pipe);
REGISTER_PROTOCOL (RTMP, rtmp);
REGISTER_PROTOCOL (RTMPHTTP, rtmphttp);
REGISTER_PROTOCOL (RTMPS, rtmps);
REGISTER_PROTOCOL (RTMPT, rtmpt);
REGISTER_PROTOCOL (RTMPTS, rtmpts);
REGISTER_PROTOCOL (RTP, rtp);
REGISTER_PROTOCOL (SCTP, sctp);
REGISTER_PROTOCOL (TCP, tcp);

@ -25,6 +25,7 @@
#include "avformat.h"
#define RTMP_DEFAULT_PORT 1935
#define RTMPS_DEFAULT_PORT 443
#define RTMP_HANDSHAKE_PACKET_SIZE 1536

@ -30,11 +30,14 @@
#include "libavutil/time.h"
#include "internal.h"
#include "http.h"
#include "rtmp.h"
#define RTMPT_DEFAULT_PORT 80
#define RTMPTS_DEFAULT_PORT RTMPS_DEFAULT_PORT
/* protocol handler context */
typedef struct RTMP_HTTPContext {
const AVClass *class;
URLContext *stream; ///< HTTP stream
char host[256]; ///< hostname of the server
int port; ///< port to connect (default is 80)
@ -46,6 +49,7 @@ typedef struct RTMP_HTTPContext {
int initialized; ///< flag indicating when the http context is initialized
int finishing; ///< flag indicating when the client closes the connection
int nb_bytes_read; ///< number of bytes read since the last request
int tls; ///< use Transport Security Layer (RTMPTS)
} RTMP_HTTPContext;
static int rtmp_http_send_cmd(URLContext *h, const char *cmd)
@ -185,9 +189,6 @@ static int rtmp_http_open(URLContext *h, const char *uri, int flags)
av_url_split(NULL, 0, NULL, 0, rt->host, sizeof(rt->host), &rt->port,
NULL, 0, uri);
if (rt->port < 0)
rt->port = RTMPT_DEFAULT_PORT;
/* This is the first request that is sent to the server in order to
* register a client on the server and start a new session. The server
* replies with a unique id (usually a number) that is used by the client
@ -195,7 +196,15 @@ static int rtmp_http_open(URLContext *h, const char *uri, int flags)
* Note: the reply doesn't contain a value for the polling interval.
* A successful connect resets the consecutive index that is used
* in the URLs. */
if (rt->tls) {
if (rt->port < 0)
rt->port = RTMPTS_DEFAULT_PORT;
ff_url_join(url, sizeof(url), "https", NULL, rt->host, rt->port, "/open/1");
} else {
if (rt->port < 0)
rt->port = RTMPT_DEFAULT_PORT;
ff_url_join(url, sizeof(url), "http", NULL, rt->host, rt->port, "/open/1");
}
/* alloc the http context */
if ((ret = ffurl_alloc(&rt->stream, url, AVIO_FLAG_READ_WRITE, NULL)) < 0)
@ -240,12 +249,28 @@ fail:
return ret;
}
URLProtocol ff_rtmphttp_protocol = {
.name = "rtmphttp",
#define OFFSET(x) offsetof(RTMP_HTTPContext, x)
#define DEC AV_OPT_FLAG_DECODING_PARAM
static const AVOption ffrtmphttp_options[] = {
{"ffrtmphttp_tls", "Use a HTTPS tunneling connection (RTMPTS).", OFFSET(tls), AV_OPT_TYPE_INT, {0}, 0, 1, DEC},
{ NULL },
};
static const AVClass ffrtmphttp_class = {
.class_name = "ffrtmphttp",
.item_name = av_default_item_name,
.option = ffrtmphttp_options,
.version = LIBAVUTIL_VERSION_INT,
};
URLProtocol ff_ffrtmphttp_protocol = {
.name = "ffrtmphttp",
.url_open = rtmp_http_open,
.url_read = rtmp_http_read,
.url_write = rtmp_http_write,
.url_close = rtmp_http_close,
.priv_data_size = sizeof(RTMP_HTTPContext),
.flags = URL_PROTOCOL_FLAG_NETWORK,
.priv_data_class= &ffrtmphttp_class,
};

@ -1111,6 +1111,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
char *old_app;
uint8_t buf[2048];
int port;
AVDictionary *opts = NULL;
int ret;
rt->is_input = !(flags & AVIO_FLAG_WRITE);
@ -1118,9 +1119,17 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port,
path, sizeof(path), s->filename);
if (!strcmp(proto, "rtmpt")) {
if (!strcmp(proto, "rtmpt") || !strcmp(proto, "rtmpts")) {
if (!strcmp(proto, "rtmpts"))
av_dict_set(&opts, "ffrtmphttp_tls", "1", 1);
/* open the http tunneling connection */
ff_url_join(buf, sizeof(buf), "rtmphttp", NULL, hostname, port, NULL);
ff_url_join(buf, sizeof(buf), "ffrtmphttp", NULL, hostname, port, NULL);
} else if (!strcmp(proto, "rtmps")) {
/* open the tls connection */
if (port < 0)
port = RTMPS_DEFAULT_PORT;
ff_url_join(buf, sizeof(buf), "tls", NULL, hostname, port, NULL);
} else {
/* open the tcp connection */
if (port < 0)
@ -1129,7 +1138,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
}
if ((ret = ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, NULL)) < 0) {
&s->interrupt_callback, &opts)) < 0) {
av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf);
goto fail;
}
@ -1261,6 +1270,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
return 0;
fail:
av_dict_free(&opts);
rtmp_close(s);
return ret;
}
@ -1444,6 +1454,24 @@ URLProtocol ff_rtmp_protocol = {
.priv_data_class= &rtmp_class,
};
static const AVClass rtmps_class = {
.class_name = "rtmps",
.item_name = av_default_item_name,
.option = rtmp_options,
.version = LIBAVUTIL_VERSION_INT,
};
URLProtocol ff_rtmps_protocol = {
.name = "rtmps",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.priv_data_size = sizeof(RTMPContext),
.flags = URL_PROTOCOL_FLAG_NETWORK,
.priv_data_class = &rtmps_class,
};
static const AVClass rtmpt_class = {
.class_name = "rtmpt",
.item_name = av_default_item_name,
@ -1461,3 +1489,21 @@ URLProtocol ff_rtmpt_protocol = {
.flags = URL_PROTOCOL_FLAG_NETWORK,
.priv_data_class = &rtmpt_class,
};
static const AVClass rtmpts_class = {
.class_name = "rtmpts",
.item_name = av_default_item_name,
.option = rtmp_options,
.version = LIBAVUTIL_VERSION_INT,
};
URLProtocol ff_rtmpts_protocol = {
.name = "rtmpts",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.priv_data_size = sizeof(RTMPContext),
.flags = URL_PROTOCOL_FLAG_NETWORK,
.priv_data_class = &rtmpts_class,
};

@ -30,8 +30,8 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MINOR 16
#define LIBAVFORMAT_VERSION_MICRO 104
#define LIBAVFORMAT_VERSION_MINOR 17
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \

Loading…
Cancel
Save