I have figured out the problem.
It was failing when it tried to match asf header with the stream. I was
downloading header during first call of libmms and thus while I try to open
stream it was failing as header was not matching.
Here is my updated code
#include <stdio.h>
#include "libmms/mmsx.h"
#include "libmms/mms.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
const char *url = "mms://live.cumulusstreaming.com/KPLX-FM";
void my_log_callback(void *ptr, int level, const char *fmt, va_list vargs)
{
printf(fmt, vargs);
}
int64_t seek_data(void *opaque, int64_t offset, int whence)
{
printf("SEEK DATA\n");
return -1;
}
int main(int argc, char *argv[])
{
mmsx_t *this = NULL;
mmsx_t *this2 = NULL;
char buf[2048];
char buf2[2048];
int i, res;
FILE* f;
AVFormatContext* pFormatCtx;
av_log_set_callback(my_log_callback);
av_log_set_level(AV_LOG_VERBOSE);
av_register_all();
int read_data(void *opaque, char *buf, int buf_size);
AVInputFormat* pAVInputFormat = av_find_input_format("asf");
if(!pAVInputFormat)
{
printf("Probe not successful\n");
}
else
{
printf("Probe successfull------%s-------%s\n",pAVInputFormat->name,
pAVInputFormat->long_name);
}
if((this = mmsx_connect(NULL, NULL, url, 1)))
printf("Connect OK\n");
//pAVInputFormat->flags |= AVFMT_NOFILE;
ByteIOContext ByteIOCtx;
if(init_put_byte(&ByteIOCtx, buf, 2048, 0, this, read_data, NULL,
seek_data) < 0)
{
printf("init_put_byte not successful\n");
}
else
{
printf("init_put_byte successful\n");
}
ByteIOCtx.is_streamed = 1;
int ires = av_open_input_stream(&pFormatCtx, &ByteIOCtx, "",
pAVInputFormat,NULL);
if(ires < 0)
{
printf("Open input stream not successful %d\n",ires);
}
else
{
printf("Open input stream successfull %d\n",ires);
}
}
int read_data(void *opaque, char *buf, int buf_size)
{
mmsx_t *this22 = (mmsx_t *)opaque;
int cnt = mmsx_read(NULL, opaque, buf, buf_size);
return cnt;
}
Thank you for all help.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kulti
Sent: 28/09/2010 4:32 PM
To: Libav* user questions and discussions
Subject: Re: [libav-user] av_open_input_stream Failing
Hm... I compare your code with my and found only one difference:
+ ByteIOCtx.is_streamed = 1;
On Tue, Sep 28, 2010 at 2:25 PM, Linux V <[email protected]> wrote:
> Thank you for help again.
>
> I changed the buffer size and made sure that it returns same size in
> read_data()
>
> Still I get -1 in av_open_input_stream and no information even after I
> set log level as AV_LOG_VERBOSE
>
> Any help would be greatly appreciated
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Kulti
> Sent: 27/09/2010 11:25 PM
> To: Libav* user questions and discussions
> Subject: Re: [libav-user] av_open_input_stream Failing
>
> On Mon, Sep 27, 2010 at 9:19 PM, Linux V <[email protected]> wrote:
>
> > Thank you for the help.
> >
> > I have added
> >
> > av_log_set_callback(my_log_callback);
> > av_log_set_level(AV_LOG_VERBOSE);
> >
> > At top of the program and added this function
> >
> > void my_log_callback(void *ptr, int level, const char *fmt, va_list
> > vargs) { if (level > av_log_get_level())
> > return;
> > vprintf(fmt, vargs);
> > }
> >
> > It still does not output any line of log.
> >
> > I am getting return value of -1 from av_open_input_stream
> >
> > Sorry for being novice here, I understand that this is pretty basic
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Mike Edenfield
> > Sent: 27/09/2010 8:54 PM
> > To: [email protected]
> > Subject: Re: [libav-user] av_open_input_stream Failing
> >
> > On 9/27/2010 10:52 AM, Linux V wrote:
> >
> > > I am not sure what is wrong here, probably I am supposed to use
> > > different code/method for ASF ? Is there any way I can get more
> > > information debug information on how it is failing?
> >
> > 1. The negative return values for the FFmpeg functions are
> > meaningful (most likely a value from libavutil/error.h); check the
> > libavformat source code to see what they represent.
> >
> > 2. You can get more debugging information from FFmpeg using
> > something
> like:
> >
> > av_log_set_callback(my_log_callback);
> > av_log_set_level(AV_LOG_DEBUG);
> >
> > void my_log_callback(void *ptr, int level, const char *fmt, va_list
> > vargs) {
> > if (level > av_log_get_level())
> > return;
> >
> > vprintf(fmt, vargs);
> > }
> > _______________________________________________
> > libav-user mailing list
> > [email protected]
> > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> >
> > _______________________________________________
> > libav-user mailing list
> > [email protected]
> > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> >
>
> As I remember, read_data() should be return the same size, as received
> in third parameter. Check it.
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user