Commit 8fc4323f authored by Sandrine Avakian's avatar Sandrine Avakian
Browse files

Updating textstream and mkv mediaplayer.

parent 081c581a
......@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <ortp/ortp.h>
#include <ortp/event.h>
#include <mediastreamer2/msfactory.h>
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/mssndcard.h>
......@@ -1204,25 +1205,28 @@ typedef struct _TextStream TextStream;
* @param loc_rtp_port the local UDP port to listen for RTP packets.
* @param loc_rtcp_port the local UDP port to listen for RTCP packets
* @param ipv6 TRUE if ipv6 must be used.
* @param factory
* @return a new TextStream.
**/
MS2_PUBLIC TextStream *text_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6);
MS2_PUBLIC TextStream *text_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6, MSFactory *factory);
/**
* Creates a TextStream object from initialized MSMediaStreamSessions.
* @param sessions the MSMediaStreamSessions
* @param factory
* @return a new TextStream
**/
MS2_PUBLIC TextStream *text_stream_new_with_sessions(const MSMediaStreamSessions *sessions);
MS2_PUBLIC TextStream *text_stream_new_with_sessions(const MSMediaStreamSessions *sessions, MSFactory *factory);
/**
* Creates a TextStream object listening on a RTP port for a dedicated address.
* @param loc_ip the local ip to listen for RTP packets. Can be ::, O.O.O.O or any ip4/6 addresses
* @param [in] loc_rtp_port the local UDP port to listen for RTP packets.
* @param [in] loc_rtcp_port the local UDP port to listen for RTCP packets
* @param factory
* @return a new TextStream.
**/
MS2_PUBLIC TextStream *text_stream_new2(const char* ip, int loc_rtp_port, int loc_rtcp_port);
MS2_PUBLIC TextStream *text_stream_new2(const char* ip, int loc_rtp_port, int loc_rtcp_port,MSFactory *factory);
/**
* Starts a text stream.
......@@ -1234,8 +1238,10 @@ MS2_PUBLIC TextStream *text_stream_new2(const char* ip, int loc_rtp_port, int lo
* @param[in] rem_rtcp_addr The remote IP address for RTCP.
* @param[in] rem_rtcp_port The remote port for RTCP.
* @param[in] payload_type The payload type number used to send the text stream. A valid PayloadType must be available at this index in the profile.
* @param[in] factory
*/
MS2_PUBLIC TextStream* text_stream_start(TextStream *stream, RtpProfile *profile, const char *rem_rtp_addr, int rem_rtp_port, const char *rem_rtcp_addr, int rem_rtcp_port, int payload_type);
MS2_PUBLIC TextStream* text_stream_start(TextStream *stream, RtpProfile *profile, const char *rem_rtp_addr, int rem_rtp_port, const char *rem_rtcp_addr, int rem_rtcp_port,
int payload_type, MSFactory *factory);
/**
* Stops the text streaming thread and free everything
......
......@@ -80,7 +80,7 @@ MS2_PUBLIC void ms_media_player_set_eof_callback(MSMediaPlayer *obj, MSMediaPlay
* @param filepath Path of the file to open
* @return TRUE if the file could be opened
*/
MS2_PUBLIC bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath);
MS2_PUBLIC bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath, MSFactory *factory);
/**
* Close a media file
......
......@@ -153,8 +153,9 @@ static void mire_cam_init(MSWebCam *cam){
cam->name=ms_strdup("Mire (synthetic moving picture)");
}
static MSFilter *mire_create_reader(MSWebCam *obj){
return ms_filter_new_from_desc(&ms_mire_desc);
static MSFilter *mire_create_reader(MSWebCam *obj, MSFactory * factory){
//return ms_filter_new_from_desc(&ms_mire_desc);
return ms_factory_create_filter_from_desc(factory, &ms_mire_desc);
}
MSWebCamDesc ms_mire_webcam_desc={
......
......@@ -2332,11 +2332,11 @@ static MKVTrackPlayer *mkv_track_player_new(MKVReader *reader, const MKVTrack *t
obj->track = track;
if(track->type == MKV_TRACK_TYPE_VIDEO) {
MKVVideoTrack *v_track = (MKVVideoTrack *)track;
MSVideoSize vsize = {v_track->width, v_track->height};
obj->output_pin_desc = ms_factory_get_video_format(ms_factory_get_fallback(), codec_name, vsize, v_track->frame_rate,NULL);
MSVideoSize vsize = {v_track->width, v_track->height};// TODO : FIX THIS !!!
obj->output_pin_desc = ms_factory_get_video_format(NULL, codec_name, vsize, v_track->frame_rate,NULL);
} else if(track->type == MKV_TRACK_TYPE_AUDIO) {
MKVAudioTrack *a_track = (MKVAudioTrack *)track;
obj->output_pin_desc = ms_factory_get_audio_format(ms_factory_get_fallback(), codec_name, a_track->sampling_freq, a_track->channels, NULL);
obj->output_pin_desc = ms_factory_get_audio_format(NULL, codec_name, a_track->sampling_freq, a_track->channels, NULL);
} else {
ms_error("MKVTrackPlayer: unsupported track type: %d", track->type);
ms_free(obj);
......
......@@ -225,7 +225,8 @@ static void enc_init(MSFilter *f, enum CodecID codec)
ms_ffmpeg_check_init();
s->profile=0;/*always default to profile 0*/
s->comp_buf=NULL;
s->mtu=ms_get_payload_max_size()-2;/*-2 for the H263 payload header*/
s->mtu=ms_factory_get_payload_max_size(f->factory)-2;/*-2 for the H263 payload header*/
// s->mtu=ms_get_payload_max_size()-2;/*-2 for the H263 payload header*/
s->codec=codec;
s->qmin=2;
s->req_vfu=FALSE;
......
......@@ -59,8 +59,8 @@ struct _MSMediaPlayer {
};
static bool_t _get_format(const char *filepath, MSFileFormat *format);
static void _create_decoders(MSMediaPlayer *obj);
static void _create_sinks(MSMediaPlayer *obj);
static void _create_decoders(MSMediaPlayer *obj, MSFactory *factory);
static void _create_sinks(MSMediaPlayer *obj, MSFactory *factory);
static void _destroy_graph(MSMediaPlayer *obj);
static bool_t _link_all(MSMediaPlayer *obj);
static void _unlink_all(MSMediaPlayer *obj);
......@@ -106,7 +106,7 @@ void * ms_media_player_get_window_id(const MSMediaPlayer *obj) {
return obj->window_id;
}
bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath) {
bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath, MSFactory* factory) {
wave_header_t header;
int fd;
char *tmp;
......@@ -135,10 +135,10 @@ bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath) {
ms_error("Cannot open %s. Codec not supported", filepath);
return FALSE;
}
obj->player = ms_filter_new(MS_FILE_PLAYER_ID);
obj->player = ms_factory_create_filter(factory, MS_FILE_PLAYER_ID);
break;
case MS_FILE_FORMAT_MATROSKA:
if((obj->player = ms_filter_new(MS_MKV_PLAYER_ID)) == NULL) {
if((obj->player = ms_factory_create_filter(factory, MS_MKV_PLAYER_ID)) == NULL) {
ms_error("Cannot open %s. Matroska file support is disabled", filepath);
return FALSE;
}
......@@ -155,8 +155,8 @@ bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath) {
return FALSE;
}
ms_free(tmp);
_create_decoders(obj);
_create_sinks(obj);
_create_decoders(obj, factory);
_create_sinks(obj, factory);
if(!_link_all(obj)) {
ms_error("Cannot open %s. Could not build playing graph", filepath);
_destroy_graph(obj);
......@@ -301,14 +301,14 @@ err:
return FALSE;
}
static void _create_decoders(MSMediaPlayer *obj) {
static void _create_decoders(MSMediaPlayer *obj, MSFactory* factory) {
int sample_rate, nchannels;
switch(obj->format) {
case MS_FILE_FORMAT_WAVE:
ms_filter_call_method(obj->player, MS_FILTER_GET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(obj->player, MS_FILTER_GET_NCHANNELS, &nchannels);
obj->audio_pin_fmt.pin = 0;
obj->audio_pin_fmt.fmt = ms_factory_get_audio_format(ms_factory_get_fallback(), "pcm", sample_rate, nchannels, NULL);
obj->audio_pin_fmt.fmt = ms_factory_get_audio_format(factory, "pcm", sample_rate, nchannels, NULL);
break;
case MS_FILE_FORMAT_MATROSKA:
obj->audio_pin_fmt.pin = 1;
......@@ -316,7 +316,7 @@ static void _create_decoders(MSMediaPlayer *obj) {
ms_filter_call_method(obj->player, MS_FILTER_GET_OUTPUT_FMT, &obj->audio_pin_fmt);
ms_filter_call_method(obj->player, MS_FILTER_GET_OUTPUT_FMT, &obj->video_pin_fmt);
if(obj->audio_pin_fmt.fmt) {
obj->audio_decoder = ms_factory_create_decoder(ms_factory_get_fallback(), obj->audio_pin_fmt.fmt->encoding);
obj->audio_decoder = ms_factory_create_decoder(factory, obj->audio_pin_fmt.fmt->encoding);
if(obj->audio_decoder == NULL) {
ms_error("Could not create audio decoder for %s", obj->audio_pin_fmt.fmt->encoding);
obj->audio_pin_fmt.fmt = NULL;
......@@ -328,7 +328,7 @@ static void _create_decoders(MSMediaPlayer *obj) {
}
}
if(obj->video_pin_fmt.fmt) {
obj->video_decoder = ms_factory_create_decoder(ms_factory_get_fallback(), obj->video_pin_fmt.fmt->encoding);
obj->video_decoder = ms_factory_create_decoder(factory, obj->video_pin_fmt.fmt->encoding);
if(obj->video_decoder == NULL) {
ms_error("Could not create video decoder for %s", obj->video_pin_fmt.fmt->encoding);
obj->video_pin_fmt.fmt = NULL;
......@@ -340,7 +340,7 @@ static void _create_decoders(MSMediaPlayer *obj) {
}
}
static void _create_sinks(MSMediaPlayer *obj) {
static void _create_sinks(MSMediaPlayer *obj, MSFactory* factory) {
int sink_sample_rate, sample_rate, nchannels;
if(obj->audio_pin_fmt.fmt && obj->snd_card) {
sample_rate = obj->audio_pin_fmt.fmt->rate;
......@@ -350,7 +350,7 @@ static void _create_sinks(MSMediaPlayer *obj) {
ms_warning("The sound card (%s) does not support %dHz", obj->snd_card->name, sample_rate);
ms_filter_call_method(obj->audio_sink, MS_FILTER_GET_SAMPLE_RATE, &sink_sample_rate);
ms_message("Resampling to %dHz", sink_sample_rate);
obj->resampler = ms_filter_new(MS_RESAMPLE_ID);
obj->resampler = ms_factory_create_filter(factory, MS_RESAMPLE_ID);
ms_filter_call_method(obj->resampler, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(obj->resampler, MS_FILTER_SET_OUTPUT_SAMPLE_RATE, &sink_sample_rate);
ms_filter_call_method(obj->resampler, MS_FILTER_SET_NCHANNELS, &nchannels);
......@@ -362,7 +362,7 @@ static void _create_sinks(MSMediaPlayer *obj) {
}
if(obj->video_pin_fmt.fmt) {
if(obj->video_display) {
obj->video_sink = ms_filter_new_from_name(obj->video_display);
obj->video_sink = ms_factory_create_filter_from_name(factory, obj->video_display);
if(obj->video_sink) {
if(obj->window_id) ms_filter_call_method(obj->video_sink, MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID, &obj->window_id);
} else {
......
......@@ -39,17 +39,17 @@ static void text_stream_free(TextStream *stream) {
static void text_stream_process_rtcp(MediaStream *media_stream, mblk_t *m) {
}
TextStream *text_stream_new_with_sessions(const MSMediaStreamSessions *sessions) {
TextStream *text_stream_new_with_sessions(const MSMediaStreamSessions *sessions, MSFactory *factory) {
TextStream *stream = (TextStream *)ms_new0(TextStream, 1);
stream->pt_red = 0;
stream->pt_t140 = 0;
stream->ms.type = MSText;
stream->ms.sessions = *sessions;
media_stream_init(&stream->ms, ms_factory_get_fallback());
media_stream_init(&stream->ms, factory);
ms_filter_enable_statistics(TRUE);
ms_filter_reset_statistics();
ms_factory_enable_statistics(factory, TRUE);
ms_factory_reset_statistics(factory);
if (sessions->zrtp_context != NULL) {
ms_zrtp_set_stream_sessions(sessions->zrtp_context, &(stream->ms.sessions));
......@@ -59,7 +59,7 @@ TextStream *text_stream_new_with_sessions(const MSMediaStreamSessions *sessions)
}
rtp_session_resync(stream->ms.sessions.rtp_session);
/*some filters are created right now to allow configuration by the application before start() */
stream->ms.rtpsend = ms_filter_new(MS_RTP_SEND_ID);
stream->ms.rtpsend = ms_factory_create_filter(factory, MS_RTP_SEND_ID);
stream->ms.ice_check_list = NULL;
stream->ms.qi = ms_quality_indicator_new(stream->ms.sessions.rtp_session);
ms_quality_indicator_set_label(stream->ms.qi, "text");
......@@ -68,20 +68,21 @@ TextStream *text_stream_new_with_sessions(const MSMediaStreamSessions *sessions)
return stream;
}
TextStream *text_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6) {
return text_stream_new2(ipv6 ? "::" : "0.0.0.0", loc_rtp_port, loc_rtcp_port);
TextStream *text_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6, MSFactory *factory) {
return text_stream_new2(ipv6 ? "::" : "0.0.0.0", loc_rtp_port, loc_rtcp_port,factory);
}
TextStream *text_stream_new2(const char* ip, int loc_rtp_port, int loc_rtcp_port) {
TextStream *text_stream_new2(const char* ip, int loc_rtp_port, int loc_rtcp_port, MSFactory *factory) {
TextStream *stream;
MSMediaStreamSessions sessions = {0};
sessions.rtp_session = ms_create_duplex_rtp_session(ip, loc_rtp_port, loc_rtcp_port);
stream = text_stream_new_with_sessions(&sessions);
stream = text_stream_new_with_sessions(&sessions, factory);
stream->ms.owns_sessions = TRUE;
return stream;
}
TextStream* text_stream_start(TextStream *stream, RtpProfile *profile, const char *rem_rtp_addr, int rem_rtp_port, const char *rem_rtcp_addr, int rem_rtcp_port, int payload_type /* ignored */) {
TextStream* text_stream_start(TextStream *stream, RtpProfile *profile, const char *rem_rtp_addr, int rem_rtp_port, const char *rem_rtcp_addr, int rem_rtcp_port, int payload_type /* ignored */,
MSFactory * factory) {
RtpSession *rtps = stream->ms.sessions.rtp_session;
MSConnectionHelper h;
......@@ -106,14 +107,14 @@ TextStream* text_stream_start(TextStream *stream, RtpProfile *profile, const cha
rtp_session_set_payload_type(rtps, payload_type);
if (rem_rtp_port > 0) ms_filter_call_method(stream->ms.rtpsend, MS_RTP_SEND_SET_SESSION, rtps);
stream->ms.rtprecv = ms_filter_new(MS_RTP_RECV_ID);
stream->ms.rtprecv = ms_factory_create_filter(factory, MS_RTP_RECV_ID);
ms_filter_call_method(stream->ms.rtprecv, MS_RTP_RECV_SET_SESSION, rtps);
stream->ms.sessions.rtp_session = rtps;
if (stream->ms.sessions.ticker == NULL) media_stream_start_ticker(&stream->ms);
stream->rttsource = ms_filter_new(MS_RTT_4103_SOURCE_ID);
stream->rttsink = ms_filter_new(MS_RTT_4103_SINK_ID);
stream->rttsource = ms_factory_create_filter(factory, MS_RTT_4103_SOURCE_ID);
stream->rttsink = ms_factory_create_filter(factory, MS_RTT_4103_SINK_ID);
ms_filter_call_method(stream->rttsource, MS_RTT_4103_SOURCE_SET_T140_PAYLOAD_TYPE_NUMBER, &stream->pt_t140);
ms_filter_call_method(stream->rttsink, MS_RTT_4103_SINK_SET_T140_PAYLOAD_TYPE_NUMBER, &stream->pt_t140);
......
......@@ -726,7 +726,7 @@ int video_stream_start_from_io(VideoStream *stream, RtpProfile *profile, const c
break;
case MSResourceCamera:
cam = io->input.camera;
source = ms_web_cam_create_reader(cam);
source = ms_web_cam_create_reader(cam, stream->ms.factory);
break;
case MSResourceFile:
source = ms_factory_create_filter(stream->ms.factory, MS_MKV_PLAYER_ID);
......@@ -1243,7 +1243,7 @@ static MSFilter* _video_stream_change_camera(VideoStream *stream, MSWebCam *cam,
ms_filter_call_method(sink,MS_ITC_SINK_CONNECT,stream->source);
stream->player_active = TRUE;
} else {
stream->source = new_source ? new_source : ms_web_cam_create_reader(cam);
stream->source = new_source ? new_source : ms_web_cam_create_reader(cam, stream->ms.factory);
stream->cam = cam;
stream->player_active = FALSE;
}
......@@ -1557,7 +1557,7 @@ void video_preview_start(VideoPreview *stream, MSWebCam *device){
if (stream->fps!=0) fps=stream->fps;
else fps=(float)29.97;
stream->source = ms_web_cam_create_reader(device);
stream->source = ms_web_cam_create_reader(device, stream->ms.factory);
/* Transmit orientation to source filter. */
if (ms_filter_has_method(stream->source, MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment