Posted: Tue Apr 22, 2008 1:36 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Dear All,
is anyone working on this issue? Or have a solution?
Regards,
Sven
Jose M. Recio wrote:
Quote:
Hi, guys,
I don't know if that's a known fact, I have discovered that, at least in my
systems, mp4save() creates mp4files with different lengths in audio and
video tracks (see examples at the end). This means that the audio track in
those files is almost useless, as it is totally out of synch with the video
...
I think this has something to do with the framesPerSample property in
mpeg4ip package, but after messing a bit with the MP4 library I have
surrended without fixing it. Have somebody tested or fixed this before?
Can you check by yourself if this behaviour also happens in your system?.
Thanks,
JM
~$ mp4info /tmp/*.mp4
mp4info version 1.5.0.1
/tmp/save.clock.1.mp4:
Track Type Info
1 audio AMR, 6.780 secs, 12 kbps, 8000 Hz
2 hint Payload AMR for track 1
3 video H.263, 9.171 secs, 47 kbps, 176x144 @ 8.614110 fps
4 hint Payload H263-1998 for track 3
/tmp/save.clock.2.mp4:
Track Type Info
1 audio AMR, 52.460 secs, 12 kbps, 8000 Hz
2 hint Payload AMR for track 1
3 video H.263, 61.413 secs, 45 kbps, 176x144 @ 9.069741 fps
4 hint Payload H263-1998 for track 3
/tmp/save.clock.3.mp4:
Track Type Info
1 audio AMR, 2.900 secs, 10 kbps, 8000 Hz
2 hint Payload AMR for track 1
3 video H.263, 6.649 secs, 49 kbps, 176x144 @ 8.572718 fps
4 hint Payload H263-1998 for track 3
~$
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Tue Apr 22, 2008 4:08 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi,
I am going to work on it.
But for the moment, I am qualifying the video transcoder and the h324m
module.
The Gateway (SIP -> 3G or 3G -> SIP) configuration locks after some
secondes or minutes if it use the transcoder.
2 ways for the recording :
- Replace the silence by generating the AMR datas with a audio silence.
- Check if we can timestamps correctly the AMR packets in the MP4/3GP
hinted file.
Regards,
Tech from i6net
Sven Brandau a écrit :
Quote:
Dear All,
is anyone working on this issue? Or have a solution?
Regards,
Sven
Jose M. Recio wrote:
> Hi, guys,
>
> I don't know if that's a known fact, I have discovered that, at least in my
> systems, mp4save() creates mp4files with different lengths in audio and
> video tracks (see examples at the end). This means that the audio track in
> those files is almost useless, as it is totally out of synch with the video
> ...
>
> I think this has something to do with the framesPerSample property in
> mpeg4ip package, but after messing a bit with the MP4 library I have
> surrended without fixing it. Have somebody tested or fixed this before?
>
> Can you check by yourself if this behaviour also happens in your system?.
>
> Thanks,
> JM
>
>
> ~$ mp4info /tmp/*.mp4
> mp4info version 1.5.0.1
> /tmp/save.clock.1.mp4:
> Track Type Info
> 1 audio AMR, 6.780 secs, 12 kbps, 8000 Hz
> 2 hint Payload AMR for track 1
> 3 video H.263, 9.171 secs, 47 kbps, 176x144 @ 8.614110 fps
> 4 hint Payload H263-1998 for track 3
> /tmp/save.clock.2.mp4:
> Track Type Info
> 1 audio AMR, 52.460 secs, 12 kbps, 8000 Hz
> 2 hint Payload AMR for track 1
> 3 video H.263, 61.413 secs, 45 kbps, 176x144 @ 9.069741 fps
> 4 hint Payload H263-1998 for track 3
> /tmp/save.clock.3.mp4:
> Track Type Info
> 1 audio AMR, 2.900 secs, 10 kbps, 8000 Hz
> 2 hint Payload AMR for track 1
> 3 video H.263, 6.649 secs, 49 kbps, 176x144 @ 8.572718 fps
> 4 hint Payload H263-1998 for track 3
> ~$
>
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-video mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-video
>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Mon May 05, 2008 9:11 am Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi,
May I know if anyone has solved the recording
audio/video length problem?
Tech from i6net wrote :
Quote:
Hi,
I am going to work on it.
But for the moment, I am qualifying the video
transcoder and the h324m module.
The Gateway (SIP -> 3G or 3G -> SIP) configuration
locks after some secondes or minutes if it use the
transcoder.
Quote:
2 ways for the recording :
- Replace the silence by generating the AMR datas
with a audio silence.
Quote:
- Check if we can timestamps correctly the AMR
packets in the MP4/3GP hinted file.
___________________________________________________________
Yahoo! For Good. Give and get cool things for free, reduce waste and help our planet. Plus find hidden Yahoo! treasure
Posted: Mon May 05, 2008 12:36 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
--------------------------
Sent from a cramped and tiny keyboard
----- Original Message -----
From: asterisk-video-bounces@lists.digium.com <asterisk-video-bounces@lists.digium.com>
To: asterisk-video@lists.digium.com <asterisk-video@lists.digium.com>
Sent: Mon May 05 03:02:48 2008
Subject: [Asterisk-video] mp4save(): different audio and video lengths
Hi,
May I know if anyone has solved the recording
audio/video length problem?
Tech from i6net wrote :
Quote:
Hi,
I am going to work on it.
But for the moment, I am qualifying the video
transcoder and the h324m module.
The Gateway (SIP -> 3G or 3G -> SIP) configuration
locks after some secondes or minutes if it use the
transcoder.
Quote:
2 ways for the recording :
- Replace the silence by generating the AMR datas
with a audio silence.
Quote:
- Check if we can timestamps correctly the AMR
packets in the MP4/3GP hinted file.
___________________________________________________________
Yahoo! For Good. Give and get cool things for free, reduce waste and help our planet. Plus find hidden Yahoo! treasure
Posted: Mon May 05, 2008 12:36 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
--------------------------
Sent from a cramped and tiny keyboard
----- Original Message -----
From: asterisk-video-bounces@lists.digium.com <asterisk-video-bounces@lists.digium.com>
To: asterisk-video@lists.digium.com <asterisk-video@lists.digium.com>
Sent: Mon May 05 03:02:48 2008
Subject: [Asterisk-video] mp4save(): different audio and video lengths
Hi,
May I know if anyone has solved the recording
audio/video length problem?
Tech from i6net wrote :
Quote:
Hi,
I am going to work on it.
But for the moment, I am qualifying the video
transcoder and the h324m module.
The Gateway (SIP -> 3G or 3G -> SIP) configuration
locks after some secondes or minutes if it use the
transcoder.
Quote:
2 ways for the recording :
- Replace the silence by generating the AMR datas
with a audio silence.
Quote:
- Check if we can timestamps correctly the AMR
packets in the MP4/3GP hinted file.
___________________________________________________________
Yahoo! For Good. Give and get cool things for free, reduce waste and help our planet. Plus find hidden Yahoo! treasure
Posted: Mon May 05, 2008 12:37 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi @All,
I'm working on a solution.
I've found that some mobile phones (Moto K3) sending out AMR No-Data
packets, instead of comfort noise frames (AMR-SID). So I replaced the
No-Data packets with the last received AMR-SID frame (file app_h324m.c /
function create_ast_frame). This solution worked fine for me.
The only thing is, that the recording for audio and video starts on a
different time - audio and video is already not synchronized, but only
a few milliseconds. It depends on the mp4save option /V - waiting for the
first I-frame.
I'm already working on this issue and will announce my solution here on the
mailing list.
Regards,
Sven
Low Yu Siang wrote:
Quote:
Hi,
May I know if anyone has solved the recording
audio/video length problem?
Tech from i6net wrote :
> Hi,
>
> I am going to work on it.
>
> But for the moment, I am qualifying the video
> transcoder and the h324m module.
> The Gateway (SIP -> 3G or 3G -> SIP) configuration
locks after some secondes or minutes if it use the
transcoder.
> 2 ways for the recording :
> - Replace the silence by generating the AMR datas
with a audio silence.
> - Check if we can timestamps correctly the AMR
packets in the MP4/3GP hinted file.
___________________________________________________________
Yahoo! For Good. Give and get cool things for free, reduce waste and help our planet. Plus find hidden Yahoo! treasure
Posted: Tue May 06, 2008 7:22 am Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi Sven
Could you send me a patch with oyour solution?
BR
Sergio
----- Original Message -----
From: Sven Brandau [mailto:brandau@gmx.de]
To: asterisk-video@lists.digium.com
Sent: Mon, 05 May 2008 15:30:33 +0200
Subject: Re: [Asterisk-video] mp4save(): different audio and video lengths
Hi @All,
I'm working on a solution.
I've found that some mobile phones (Moto K3) sending out AMR No-Data
packets, instead of comfort noise frames (AMR-SID). So I replaced the
No-Data packets with the last received AMR-SID frame (file app_h324m.c /
function create_ast_frame). This solution worked fine for me.
The only thing is, that the recording for audio and video starts on a
different time - audio and video is already not synchronized, but only
a few milliseconds. It depends on the mp4save option /V - waiting for the
first I-frame.
I'm already working on this issue and will announce my solution here on the
mailing list.
Regards,
Sven
Low Yu Siang wrote:
Quote:
Hi,
May I know if anyone has solved the recording
audio/video length problem?
Tech from i6net wrote :
> Hi,
>
> I am going to work on it.
>
> But for the moment, I am qualifying the video
> transcoder and the h324m module.
> The Gateway (SIP -> 3G or 3G -> SIP) configuration
locks after some secondes or minutes if it use the
transcoder.
> 2 ways for the recording :
> - Replace the silence by generating the AMR datas
with a audio silence.
> - Check if we can timestamps correctly the AMR
packets in the MP4/3GP hinted file.
___________________________________________________________
Yahoo! For Good. Give and get cool things for free, reduce waste and help our planet. Plus find hidden Yahoo! treasure
Posted: Tue May 06, 2008 6:40 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi @All,
recording to the questions, I've send you my patch.
Please note that the patch is NOT really tested - please try it
and send me your results.
Patch it with (R213):
patch -i app_h324m.c.patch
Regards,
Sven
Sergio Garcia Murillo wrote:
Quote:
Hi Sven
Could you send me a patch with oyour solution?
BR
Sergio
----- Original Message -----
From: Sven Brandau [mailto:brandau@gmx.de]
To: asterisk-video@lists.digium.com
Sent: Mon, 05 May 2008 15:30:33 +0200
Subject: Re: [Asterisk-video] mp4save(): different audio and video lengths
Hi @All,
I'm working on a solution.
I've found that some mobile phones (Moto K3) sending out AMR No-Data
packets, instead of comfort noise frames (AMR-SID). So I replaced the
No-Data packets with the last received AMR-SID frame (file app_h324m.c /
function create_ast_frame). This solution worked fine for me.
The only thing is, that the recording for audio and video starts on a
different time - audio and video is already not synchronized, but only
a few milliseconds. It depends on the mp4save option /V - waiting for the
first I-frame.
I'm already working on this issue and will announce my solution here on the
mailing list.
Regards,
Sven
Low Yu Siang wrote:
> Hi,
>
> May I know if anyone has solved the recording
> audio/video length problem?
>
> Tech from i6net wrote :
>> Hi,
>>
>> I am going to work on it.
>>
>> But for the moment, I am qualifying the video
>> transcoder and the h324m module.
>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
> locks after some secondes or minutes if it use the
> transcoder.
>> 2 ways for the recording :
>> - Replace the silence by generating the AMR datas
> with a audio silence.
>> - Check if we can timestamps correctly the AMR
> packets in the MP4/3GP hinted file.
>
/*
* Asterisk -- An open source telephony toolkit.
*
* Sergio Garcia Murillo <sergio.garcia@ydilo.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
static char *name_h324m_loopback = "h324m_loopback";
static char *syn_h324m_loopback = "H324m loopback mode";
static char *des_h324m_loopback = " h324m_loopback([options]): Establish H.324M connection and loopback media.\n"
"\n"
"Note: By default this function loops audio and video. Looping audio can cause\n"
"acoustic feedback. To prevent this you can turn it off using the 'a' option.\n"
"\n"
"Available options:\n"
" 'a': deactivate loopback of audio\n"
" 'v': deactivate loopback of video\n"
"\n"
"Note: This function just loops the h324m audio and video frames. Thus, there \n"
"is no conversion from h324m frames into Asterisk internal frame format. If \n"
"you want to test the conversion from h324m frames to Asterisk frames and \n"
"vice versa too, do not use h324m_loopback() but use h324m_gw() and the Echo()\n"
"application.\n"
"\n"
"Examples:\n"
" h324m_loopback(): loopback audio and video\n"
" h324m_loopback(a): deactivate loopback of audio\n"
" h324m_loopback(v): deactivate loopback of video\n"
" h324m_loopback(av): deactivate loopback of audio and video\n";
static char *name_h324m_gw = "h324m_gw";
static char *syn_h324m_gw = "H324m gateway";
static char *des_h324m_gw = " h324m_gw(extension@context): Creates a pseudo channel for an incoming h324m call.\n"
"This function decodes the received H.324M data (usually via a ISDN connection\n"
"and extracts the video and voice frames into Asterisk's internal frame format\n"
"and vice versa.\n"
"A pseudo channel will be created to continue dialplan execution at another\n"
"extension/context.\n"
"\n"
"Examples:\n"
" [frompstn]\n"
" exten => 111,1,h324m_gw(britney@3gp_videos)\n"
" exten => 112,1,h324m_gw(justin@3gp_videos)\n"
" [3gp_videos]\n"
" exten => britney,1,h324m_gw_answer()\n"
" exten => britney,2,mp4_play(/var/videos/britney.3gp)\n"
" exten => justin,1,h324m_gw_answer()\n"
" exten => justin,2,mp4_play(/var/videos/justin.3gp)\n";
static char *name_h324m_call = "h324m_call";
static char *syn_h324m_call = "H324m call";
static char *des_h324m_call = " h324m_call(extension@context): Creates a pseudo channel for an outgoing h324m call.\n"
"This function encodes the video and voice frames from Asterisk's internal\n"
" frame format into H.324M data and vice versa.\n"
"A pseudo channel will be created to continue dialplan execution at another\n"
"extension/context.\n"
"\n"
"Examples:\n"
" [fromsip]\n"
" ;prefix 0 means PSTN with normal audio call\n"
" ;prefix 1 means PSTN with 3G video calls\n"
" exten => _0X.,1,Dial(Zap/${EXTEN:1}\n"
" exten => _1X.,1,h324m_call(0${EXTEN:1}@fromsip)\n";
static char *name_h324m_gw_answer = "h324m_gw_answer";
static char *syn_h324m_gw_answer = "H324m Answer incoming call";
static char *des_h324m_gw_answer = " h324m_gw_answer(): Answer an incomming call from h324m_gw and waits for 3G negotiation.\n";
static char *name_video_loopback = "video_loopback";
static char *syn_video_loopback = "video_loopback";
static char *des_video_loopback = " video_loopback(): Video loopback.\n"
"This function just loops the Asterisk video frames. Thus, it is similar\n"
"to the Echo() application but only loops video (the Echo application loops\n"
"audio and video). To use this function with H324M calls you first have to use\n"
"the h324m_gw() function.\n";
/* Commands */
static int h324m_do_debug(int fd, int argc, char *argv[])
{
int level;
/* Check number of arguments */
if (argc != 4)
return RESULT_SHOWUSAGE;
static struct ast_frame* create_ast_frame(void *frame, struct video_creator *vt)
{
int mark = 0;
unsigned int i = 0;
short j = 0;
int found = 0;
unsigned int len = 0;
struct ast_frame* send;
unsigned char* data = 0;
/* Set data */
send->data = (unsigned char*)send + AST_FRIENDLY_OFFSET + sizeof(struct ast_frame);
data = send->data;
/* Depending on the type */
switch(FrameGetType(frame))
{
case MEDIA_AUDIO:
/*Check it's AMR */
if (FrameGetCodec(frame)!=CODEC_AMR)
/* exit */
return NULL;
ast_log(LOG_DEBUG, "create_ast_frame: received AMR frame with %d bytes\n",framelength);
/* Set video type */
send->frametype = AST_FRAME_VOICE;
/* Set codec value */
send->subclass = AST_FORMAT_AMRNB;
/* Rest of values*/
send->src = "h324m";
send->samples = 160;
send->delivery.tv_usec = 0;
send->delivery.tv_sec = 0;
/* Don't free */
send->mallocd = 0;
/* Send */
return send;
case MEDIA_VIDEO:
/*Check it's H263 */
if (FrameGetCodec(frame)!=CODEC_H263)
/* exit */
return NULL;
/* Search from the begining */
i = 0;
found = 0;
/* Check length*/
if(framelength>3)
{
/* Try to find begining of frame */
while (!found && i<framelength-4)
{
/* Check if we found start code */
if (framedata[i] == 0 && framedata[i+1] == 0 && (framedata[i+2] & 0xFC) == 0x80)
/* We found it */
found = 1;
else
/* Increase pointer */
i++;
}
}
/* If still in the same frame */
if (found)
{
/* Send what was on the buffer plus the beggining of the packet*/
len = vt->bufferLength + i;
/* Last packet */
mark = 1;
/* Update recived ts */
vt->tvnext = ast_tvnow();
} else {
/* Send only what was on the buffer */
len = vt->bufferLength;
/* Not last packet */
mark = 0;
}
/* if its first pcaket of a frame */
if (vt->first)
{
/* If it's not empty */
if (vt->bufferLength)
{
/* Set data len */
send->datalen = vt->bufferLength;
/* Copy */
memcpy(data+2, vt->buffer+2, vt->bufferLength-2);
} else {
/* Only header part by bow */
send->datalen = 2;
}
/* Set header */
data[0] = 0x04;
data[1] = 0x00;
} else {
/* Set data len */
send->datalen = vt->bufferLength + 2 ;
/* If it's not empty */
if (vt->bufferLength)
/* Copy */
memcpy(data+2, vt->buffer, vt->bufferLength);
/* Set header */
data[0] = 0x00;
data[1] = 0x00;
}
/* Assertion test */
if (i>framelength)
{
/* Never should happen */
ast_log(LOG_ERROR, "Counter past of frame [%d,%d]\n",i,framelength);
/* Empty */
vt->bufferLength = 0;
/* If we have to send the begging of this frame */
} else if (i>0 && found) {
/* Copy the begining to the packet to send*/
memcpy(data+send->datalen,framedata,i);
/* Increase size */
send->datalen += i;
/* Copy the rest to the buffer */
memcpy(vt->buffer,framedata+i,framelength-i);
/* Set buffer length */
vt->bufferLength = framelength-i;
} else {
/* Copy the whole packet to the buffer */
memcpy(vt->buffer,framedata,framelength);
/* Set buffer length */
vt->bufferLength = framelength;
}
/* Set video type */
send->frametype = AST_FRAME_VIDEO;
/* Set codec value */
send->subclass = AST_FORMAT_H263_PLUS | mark;
/* Rest of values*/
send->src = "h324m";
send->samples = vt->samples;
send->delivery.tv_usec = 0;
send->delivery.tv_sec = 0;
/* Don't free */
send->mallocd = 0;
/* If the next packet is from a different frame */
if (mark)
{
/* Calculate ms */
int ms = 0;
/* If it's not first*/
if (!ast_tvzero(vt->tv))
/* Get the difference in ms */
ms = ast_tvdiff_ms(vt->tvnext,vt->tv);
/* Change tr */
vt->tv = vt->tvnext;
/* Update samles */
vt->samples = ms*90;
/* Set it's the first */
vt->first = 1;
} else {
/* Next it's not first */
vt->first = 0;
}
/* Send */
return send;
}
/* NOthing */
return NULL;
}
struct h324m_packetizer
{
unsigned char *framedata;
unsigned char *offset;
int framelength;
int num;
int max;
};
static int init_h324m_packetizer(struct h324m_packetizer *pak,struct ast_frame* f)
{
int i;
/* Empty data */
memset(pak,0,sizeof(struct h324m_packetizer));
/* Depending on the type */
switch (f->frametype)
{
case AST_FRAME_VOICE:
/* Check audio type */
if (!(f->subclass & AST_FORMAT_AMRNB))
/* exit */
return 0;
/* Get data & length */
pak->framedata = (unsigned char *)f->data;
pak->framelength = f->datalen;
/* Read toc until no mark found, skip first byte */
while ((++pak->max < pak->framelength) && (pak->framedata[pak->max] & 0x80)) {}
/* Check lenght */
if (pak->max >= pak->framelength)
/* Exit */
return 0;
ast_log(LOG_DEBUG, "init_h324m_packetizer: found %d AMR frames inside ast_frame\n",pak->max);
/* Set offset */
pak->offset = pak->framedata + pak->max + 1; /* +1 because of CMR octet */
/* Move toc to the beginning so we can overwrite the byte before the frame */
/* This overwrites the CMR but it is not needed at all */
for (i=0;i < pak->max;i++)
/* copy */
pak->framedata[i] = pak->framedata[i+1];
/* Good one */
return 1;
case AST_FRAME_VIDEO:
/* Depending on the codec */
if (f->subclass & AST_FORMAT_H263)
{
/* Get data & length without rfc 2190 (only A packets ) */
pak->framedata = (unsigned char *)f->data+4;
pak->framelength = f->datalen-4;
} else if (f->subclass & AST_FORMAT_H263_PLUS) {
/* Get initial data */
pak->framedata = (unsigned char *)f->data;
pak->framelength = f->datalen;
/* Get header */
unsigned char p = pak->framedata[0] & 0x04;
unsigned char v = pak->framedata[0] & 0x02;
unsigned char plen = ((pak->framedata[0] & 0x1 ) << 5 ) | (pak->framedata[1] >> 3);
unsigned char pebit = pak->framedata[0] & 0x7;
/* skip header*/
pak->framedata += 2+plen;
pak->framelength -= 2+plen;
/* Check */
if (v)
{
/* Increase ini */
pak->framedata++;
pak->framelength--;
}
/* Check p bit */
if (p)
{
/* Decrease ini */
pak->framedata -= 2;
pak->framelength += 2;
/* Append 0s */
pak->framedata[0] = 0;
pak->framedata[1] = 0;
}
} else
break;
/* Only 1 packet */
pak->max = 1;
/* Exit */
return 1;
default:
/* dummy statement to make compiler happy */
;
}
/* Nothing to do */
return 0;
}
static void* create_h324m_frame(struct h324m_packetizer *pak,struct ast_frame* f)
{
int i = 0;
/* if not more */
if (pak->num == pak->max) {
/* Exit */
return NULL;
}
pak->num++;
ast_log(LOG_DEBUG, "create_h324m_frame: processing AMR frame #%d inside ast_frame\n",pak->num);
/* Depending on the type */
switch (f->frametype)
{
case AST_FRAME_VOICE:
/* Check audio type */
if (!(f->subclass & AST_FORMAT_AMRNB))
/* exit */
break;
/* Convert to if2 */
/* Get header: pak->framedata starts with ToC as CMR was
overwritten in init_h324m_packetizer() */
unsigned char header = pak->framedata[pak->num-1];
/* Get mode */
unsigned char mode = (header >> 3 ) & 0x0f;
/* Get blockSize */
signed bs = blockSize[mode];
if (bs < 0) {
ast_log(LOG_DEBUG, "create_h324m_frame: error decoding AMR structure - AMR frame #%d has block size %d\n",
pak->num,bs);
/* exit */
break;
}
/*Get Stuffing bits*/
int stuf = if2stuffing[mode];
/* Check input paramaters */
if (strchr(data,'v'))
/* deactivate video loopback */
loop_video=0;
/* Create session */
void* id = H324MSessionCreate();
/* Init session */
H324MSessionInit(id);
/* Wait for data avaiable on channel */
while (ast_waitfor(chan, -1) > -1)
{
/* Read frame from channel */
f = ast_read(chan);
/* if it's null */
if (f == NULL)
break;
/* Check frame type */
if (f->frametype == AST_FRAME_VOICE)
{
/* read data */
H324MSessionRead(id, (unsigned char *)f->data, f->datalen);
/* Get frames */
while ((frame=H324MSessionGetFrame(id))!=NULL)
{
if (FrameGetType(frame)==MEDIA_VIDEO)
{
/* If video loopback is activated */
if (loop_video)
/* Send it back */
H324MSessionSendFrame(id,frame);
} else if (FrameGetType(frame)==MEDIA_AUDIO) {
/* If audio loopback is activated */
if (loop_audio)
/* Send it back. Note: this can cause loopback/echo problems */
H324MSessionSendFrame(id,frame);
}
/* Delete frame */
FrameDestroy(frame);
}
/* write data */
H324MSessionWrite(id, (unsigned char *)f->data, f->datalen);
/* deliver now */
f->delivery.tv_usec = 0;
f->delivery.tv_sec = 0;
/* write frame */
ast_write(chan, f);
}
}
/* Destroy session */
H324MSessionEnd(id);
/* Destroy session */
H324MSessionDestroy(id);
ast_log(LOG_DEBUG, "exit");
/* Unlock module*/
ast_module_user_remove(u);
//Exit
return 0;
}
static int app_h324m_gw(struct ast_channel *chan, void *data)
{
struct ast_frame *f;
struct ast_frame *send;
struct ast_module_user *u;
struct h324m_packetizer pak;
struct video_creator vt;
void* frame;
char* input;
char* src = 0;
int reason = 0;
int state = 0;
int ms;
struct ast_channel *channels[2];
struct ast_channel *pseudo;
struct ast_channel *where;
/* If somthing has gone wrong */
if (!pseudo)
/* goto end */
goto end;
/* Set caller id */
ast_set_callerid(pseudo, chan->cid.cid_num, chan->cid.cid_name, chan->cid.cid_num);
/* Place call */
if (ast_call(pseudo,data,0))
/* if fail goto clean */
goto clean_pseudo;
/* Set up array */
channels[0] = chan;
channels[1] = pseudo;
/* No timeout */
ms = -1;
/* while not setup */
while (pseudo->_state!=AST_STATE_UP)
{
/* Wait for data */
if ((where = ast_waitfor_n(channels, 2, &ms))<0)
/* error, timeout, or done */
break;
/* Read frame */
f = ast_read(where);
/* If not frame */
if (!f)
/* done */
break;
/* Check channel */
if (where==pseudo)
{
/* If it's a control frame */
if (f->frametype == AST_FRAME_CONTROL)
{
/* Dependinf on the event */
switch (f->subclass)
{
case AST_CONTROL_RINGING:
ast_indicate(chan, AST_CONTROL_RINGING);
break;
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
/* Delete frame */
ast_frfree(f);
/* Save cause */
reason = pseudo->hangupcause;
/* exit */
goto hangup_pseudo;
break;
case AST_CONTROL_ANSWER:
/* Set UP*/
reason = 0;
break;
}
}
} else {
/* If it's a control frame */
if (f->frametype == AST_FRAME_CONTROL)
{
/* Depending on the event */
switch (f->subclass)
{
case AST_CONTROL_HANGUP:
/* Delete frame */
ast_frfree(f);
/* Save cause */
reason = pseudo->hangupcause;
/* exit */
goto hangup_pseudo;
break;
}
}
}
/* Delete frame */
ast_frfree(f);
}
/* If no answer */
if (pseudo->_state != AST_STATE_UP)
/* goto end */
goto clean_pseudo;
/* Create session */
void* id = H324MSessionCreate();
/* Init session */
H324MSessionInit(id);
/* Answer call */
ast_answer(chan);
/* Wait for data avaiable on any channel */
while (!reason && (where = ast_waitfor_n(channels, 2, &ms)) != NULL)
{
/* Read frame from channel */
f = ast_read(where);
/* if it's null */
if (f == NULL)
break;
/* If it's on h324m channel */
if (where==chan)
{
/* Check frame type */
if ((f->frametype == AST_FRAME_DIGITAL) || (f->frametype == AST_FRAME_VOICE))
{
/* read data */
H324MSessionRead(id, (unsigned char *)f->data, f->datalen);
/* If state changed */
if (state!=H324MSessionGetState(id))
{
/* Update state */
state = H324MSessionGetState(id);
/* Log */
ast_log(LOG_DEBUG, "H324M changed state %d\n", state);
/* If connected */
if (state==CALLSTATE_STABLISHED)
{
/* Log */
ast_log(LOG_DEBUG, "Connected, sending VIDUPDATE\n");
/* Indicate Video Update */
ast_indicate(pseudo, AST_CONTROL_VIDUPDATE);
}
}
/* Get frames */
while ((frame=H324MSessionGetFrame(id))!=NULL)
{
/* Packetize outgoing frame */
if ((send=create_ast_frame(frame,&vt))!=NULL)
/* Send frame */
ast_write(pseudo,send);
/* Delete frame */
FrameDestroy(frame);
}
/* Get user input */
while((input=H324MSessionGetUserInput(id))!=NULL)
{
/* Send digit begin */
ast_senddigit_begin(pseudo,input[0]);
/* Send digit end */
ast_senddigit_end(pseudo,input[0],100);
/* free data */
free(input);
}
/* we only do support AMR as voice codec - thus make sure that
Asterisk's core transcode voice frames to/from AMR */
if (ast_set_read_format(chan, AST_FORMAT_AMRNB))
ast_log(LOG_WARNING, "app_h324m_call: Unable to set read format to AMR-NB!\n");
if (ast_set_write_format(chan, AST_FORMAT_AMRNB))
ast_log(LOG_WARNING, "app_h324m_call: Unable to set read format to AMR-NB!\n");
/* Request new channel */
/* sometimes Asterisk uses internally a differnt LAW then chan_zap/zaptel and
* performs ALAW/ULAW conversion. Is is deadly as we transmit digital data inside
* LAW-frames (we have to do this as Asterisk does not support digital ISDN calls).
*
* If you have problems on outgoing 3G calls please specify exactly the LAW used
* by your ISDN line. Usually in Europe you have ALAW, in USA ULAW.
*
* Example for Austria(Europe):
* pseudo = ast_request("Local", AST_FORMAT_ALAW , data, &reason);
*/
pseudo = ast_request("Local", AST_FORMAT_ALAW | AST_FORMAT_ULAW, data, &reason);
/* If somthing has gone wrong */
if (!pseudo)
/* goto end */
goto end;
/* Set caller id */
ast_set_callerid(pseudo, chan->cid.cid_num, chan->cid.cid_name, chan->cid.cid_num);
/* Place call */
if (ast_call(pseudo,data,0))
/* if fail goto clean */
goto clean_pseudo;
/* Set up array */
channels[0] = chan;
channels[1] = pseudo;
/* No timeout */
ms = -1;
/* while not setup */
while (pseudo->_state!=AST_STATE_UP)
{
/* Wait for data */
if ((where = ast_waitfor_n(channels, 2, &ms))<0)
/* error, timeout, or done */
break;
/* Read frame */
f = ast_read(where);
/* If not frame */
if (!f)
/* done */
break;
/* Check channel */
if (where==pseudo)
{
/* If it's a control frame */
if (f->frametype == AST_FRAME_CONTROL)
{
/* Depending on the event */
switch (f->subclass)
{
case AST_CONTROL_RINGING:
ast_indicate(chan, AST_CONTROL_RINGING);
break;
case AST_CONTROL_BUSY:
ast_log(LOG_DEBUG, "h324m_call: pseudo channel: BUSY\n");
ast_log(LOG_DEBUG, "h324m_call: pseudo channel: hangupcause=%d\n",pseudo->hangupcause);
/* Delete frame */
ast_frfree(f);
/* Save cause */
reason = AST_CAUSE_BUSY;
/* exit */
goto hangup_pseudo;
break;
case AST_CONTROL_CONGESTION:
ast_log(LOG_DEBUG, "h324m_call: pseudo channel: CONGESTION\n");
ast_log(LOG_DEBUG, "h324m_call: pseudo channel: hangupcause=%d\n",pseudo->hangupcause);
/* Delete frame */
ast_frfree(f);
/* Save cause */
reason = AST_CAUSE_CONGESTION;
/* exit */
goto hangup_pseudo;
break;
case AST_CONTROL_ANSWER:
/* Set UP*/
reason = 0;
break;
default:
reason = pseudo->hangupcause;
}
}
} else {
/* If it's a control frame */
if (f->frametype == AST_FRAME_CONTROL)
{
/* Depending on the event */
switch (f->subclass)
{
case AST_CONTROL_HANGUP:
/* Delete frame */
ast_frfree(f);
/* Save cause */
reason = pseudo->hangupcause;
/* exit */
goto hangup_pseudo;
break;
}
}
}
/* Delete frame */
ast_frfree(f);
}
/* If no answer */
if (pseudo->_state != AST_STATE_UP)
{ ast_log(LOG_DEBUG, "h324m_call: pseudo channel not up -> hangup\n");
/* goto end */
goto clean_pseudo;
}
/* Create session */
void* id = H324MSessionCreate();
/* Init session */
H324MSessionInit(id);
/* Create enpty packet */
send = (struct ast_frame *) malloc(sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 160 );
/* No data*/
send->data = (void*)send + AST_FRIENDLY_OFFSET;
send->datalen = 160;
/* Set DTMF type */
send->frametype = AST_FRAME_VOICE;
/* Set DTMF value */
send->subclass = pseudo->rawwriteformat;
/* Rest of values*/
send->src = 0;
send->samples = 160;
send->delivery.tv_usec = 0;
send->delivery.tv_sec = 0;
/* We will free the frame */
send->mallocd = 0;
/* Send */
ast_write(pseudo,send);
/* Wait for data avaiable on any channel */
while (!reason && (where = ast_waitfor_n(channels, 2, &ms)) != NULL)
{
/* Read frame from channel */
f = ast_read(where);
/* if it's null */
if (f == NULL)
break;
/* If it's on h324m channel */
if (where==pseudo)
{
/* Check frame type */
if (f->frametype == AST_FRAME_VOICE)
{
/* read data */
H324MSessionRead(id, (unsigned char *)f->data, f->datalen);
/* If state changed */
if (state!=H324MSessionGetState(id))
{
/* Update state */
state = H324MSessionGetState(id);
/* Log */
ast_log(LOG_DEBUG, "H324M changed state %d\n", state);
/* If connected */
if (state==CALLSTATE_STABLISHED)
{
/* Answer call if not done yet */
ast_answer(chan);
/* Log */
ast_log(LOG_DEBUG, "Connected, sending VIDUPDATE\n");
/* Indicate Video Update */
ast_indicate(pseudo, AST_CONTROL_VIDUPDATE);
}
}
/* Get frames */
while ((frame=H324MSessionGetFrame(id))!=NULL)
{
/* Packetize outgoing frame */
if ((send=create_ast_frame(frame,&vt))!=NULL)
/* Send frame */
ast_write(chan,send);
/* Delete frame */
FrameDestroy(frame);
}
/* Get user input */
while((input=H324MSessionGetUserInput(id))!=NULL)
{
/* Send digit begin */
ast_senddigit_begin(chan,input[0]);
/* Send digit end */
ast_senddigit_end(chan,input[0],100);
/* free data */
free(input);
}
/* Wait for data avaiable on channel */
while (ast_waitfor(chan, -1) > -1)
{
/* Read frame from channel */
f = ast_read(chan);
/* if it's null */
if (f == NULL)
break;
/* Check frame type */
if (f->frametype == AST_FRAME_VIDEO)
{
/* deliver now */
f->delivery.tv_usec = 0;
f->delivery.tv_sec = 0;
/* write frame */
ast_write(chan, f);
}
}
ast_log(LOG_DEBUG, "exit");
/* Unlock module*/
ast_module_user_remove(u);
/* Exit */
return 0;
}
static int unload_module(void)
{
int res;
res = ast_unregister_application(name_h324m_loopback);
res &= ast_unregister_application(name_h324m_gw);
res &= ast_unregister_application(name_h324m_call);
res &= ast_unregister_application(name_h324m_gw_answer);
res &= ast_unregister_application(name_video_loopback);
ast_module_user_hangup_all();
return res;
}
static int load_module(void)
{
int res;
res = ast_register_application(name_h324m_loopback, app_h324m_loopback, syn_h324m_loopback, des_h324m_loopback);
res &= ast_register_application(name_h324m_gw, app_h324m_gw, syn_h324m_gw, des_h324m_gw);
res &= ast_register_application(name_h324m_call, app_h324m_call, syn_h324m_call, des_h324m_call);
res &= ast_register_application(name_h324m_gw_answer, app_h324m_gw_answer, syn_h324m_gw_answer, des_h324m_gw_answer);
res &= ast_register_application(name_video_loopback, app_video_loopback, syn_video_loopback, des_video_loopback);
ast_cli_register(&cli_debug);
/* No loging by default */
H324MLoggerSetLevel(1);
Posted: Tue May 06, 2008 6:43 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Yes, please, if anyone test it, send the results to the list so we can
commit the patch to the repository.
A priori I see it quite clea, so I think it won't do any harm at all
(another issue is if it solves the problem :)
BR
Sergio
Sven Brandau escribió:
Quote:
Hi @All,
recording to the questions, I've send you my patch.
Please note that the patch is NOT really tested - please try it
and send me your results.
Patch it with (R213):
patch -i app_h324m.c.patch
Regards,
Sven
Sergio Garcia Murillo wrote:
> Hi Sven
>
> Could you send me a patch with oyour solution?
>
> BR
> Sergio
>
> ----- Original Message -----
> From: Sven Brandau [mailto:brandau@gmx.de]
> To: asterisk-video@lists.digium.com
> Sent: Mon, 05 May 2008 15:30:33 +0200
> Subject: Re: [Asterisk-video] mp4save(): different audio and video
> lengths
>
> Hi @All,
>
> I'm working on a solution.
>
> I've found that some mobile phones (Moto K3) sending out AMR No-Data
> packets, instead of comfort noise frames (AMR-SID). So I replaced the
> No-Data packets with the last received AMR-SID frame (file app_h324m.c /
> function create_ast_frame). This solution worked fine for me.
>
> The only thing is, that the recording for audio and video starts on a
> different time - audio and video is already not synchronized, but only
> a few milliseconds. It depends on the mp4save option /V - waiting for
> the
> first I-frame.
>
> I'm already working on this issue and will announce my solution here
> on the
> mailing list.
>
> Regards,
> Sven
>
> Low Yu Siang wrote:
>> Hi,
>>
>> May I know if anyone has solved the recording
>> audio/video length problem?
>>
>> Tech from i6net wrote :
>>> Hi,
>>>
>>> I am going to work on it.
>>>
>>> But for the moment, I am qualifying the video transcoder and the
>>> h324m module.
>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>> locks after some secondes or minutes if it use the
>> transcoder.
>>> 2 ways for the recording :
>>> - Replace the silence by generating the AMR datas
>> with a audio silence.
>>> - Check if we can timestamps correctly the AMR
>> packets in the MP4/3GP hinted file.
>>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Yes, please, if anyone test it, send the results to the list so we can
commit the patch to the repository.
A priori I see it quite clea, so I think it won't do any harm at all
(another issue is if it solves the problem :)
BR
Sergio
Sven Brandau escribió:
> Hi @All,
>
> recording to the questions, I've send you my patch.
>
> Please note that the patch is NOT really tested - please try it
> and send me your results.
>
> Patch it with (R213):
> patch -i app_h324m.c.patch
>
> Regards,
> Sven
>
>
>
>
> Sergio Garcia Murillo wrote:
>
>> Hi Sven
>>
>> Could you send me a patch with oyour solution?
>>
>> BR
>> Sergio
>>
>> ----- Original Message -----
>> From: Sven Brandau [mailto:brandau@gmx.de]
>> To: asterisk-video@lists.digium.com
>> Sent: Mon, 05 May 2008 15:30:33 +0200
>> Subject: Re: [Asterisk-video] mp4save(): different audio and video
>> lengths
>>
>> Hi @All,
>>
>> I'm working on a solution.
>>
>> I've found that some mobile phones (Moto K3) sending out AMR No-Data
>> packets, instead of comfort noise frames (AMR-SID). So I replaced the
>> No-Data packets with the last received AMR-SID frame (file app_h324m.c /
>> function create_ast_frame). This solution worked fine for me.
>>
>> The only thing is, that the recording for audio and video starts on a
>> different time - audio and video is already not synchronized, but only
>> a few milliseconds. It depends on the mp4save option /V - waiting for
>> the
>> first I-frame.
>>
>> I'm already working on this issue and will announce my solution here
>> on the
>> mailing list.
>>
>> Regards,
>> Sven
>>
>> Low Yu Siang wrote:
>>
>>> Hi,
>>>
>>> May I know if anyone has solved the recording
>>> audio/video length problem?
>>>
>>> Tech from i6net wrote :
>>>
>>>> Hi,
>>>>
>>>> I am going to work on it.
>>>>
>>>> But for the moment, I am qualifying the video transcoder and the
>>>> h324m module.
>>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>>>>
>>> locks after some secondes or minutes if it use the
>>> transcoder.
>>>
>>>> 2 ways for the recording :
>>>> - Replace the silence by generating the AMR datas
>>>>
>>> with a audio silence.
>>>
>>>> - Check if we can timestamps correctly the AMR
>>>>
>>> packets in the MP4/3GP hinted file.
>>>
>>>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Sergio Garcia Murillo a écrit :
> Yes, please, if anyone test it, send the results to the list so we
> can commit the patch to the repository.
> A priori I see it quite clea, so I think it won't do any harm at all
> (another issue is if it solves the problem :)
>
> BR
> Sergio
>
> Sven Brandau escribió:
>
>> Hi @All,
>>
>> recording to the questions, I've send you my patch.
>>
>> Please note that the patch is NOT really tested - please try it
>> and send me your results.
>>
>> Patch it with (R213):
>> patch -i app_h324m.c.patch
>>
>> Regards,
>> Sven
>>
>>
>>
>>
>> Sergio Garcia Murillo wrote:
>>
>>> Hi Sven
>>>
>>> Could you send me a patch with oyour solution?
>>>
>>> BR
>>> Sergio
>>>
>>> ----- Original Message -----
>>> From: Sven Brandau [mailto:brandau@gmx.de]
>>> To: asterisk-video@lists.digium.com
>>> Sent: Mon, 05 May 2008 15:30:33 +0200
>>> Subject: Re: [Asterisk-video] mp4save(): different audio and video
>>> lengths
>>>
>>> Hi @All,
>>>
>>> I'm working on a solution.
>>>
>>> I've found that some mobile phones (Moto K3) sending out AMR No-Data
>>> packets, instead of comfort noise frames (AMR-SID). So I replaced the
>>> No-Data packets with the last received AMR-SID frame (file
>>> app_h324m.c /
>>> function create_ast_frame). This solution worked fine for me.
>>>
>>> The only thing is, that the recording for audio and video starts on a
>>> different time - audio and video is already not synchronized, but only
>>> a few milliseconds. It depends on the mp4save option /V - waiting
>>> for the
>>> first I-frame.
>>>
>>> I'm already working on this issue and will announce my solution
>>> here on the
>>> mailing list.
>>>
>>> Regards,
>>> Sven
>>>
>>> Low Yu Siang wrote:
>>>
>>>> Hi,
>>>>
>>>> May I know if anyone has solved the recording
>>>> audio/video length problem?
>>>>
>>>> Tech from i6net wrote :
>>>>
>>>>> Hi,
>>>>>
>>>>> I am going to work on it.
>>>>>
>>>>> But for the moment, I am qualifying the video transcoder and the
>>>>> h324m module.
>>>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>>>>>
>>>> locks after some secondes or minutes if it use the
>>>> transcoder.
>>>>
>>>>> 2 ways for the recording :
>>>>> - Replace the silence by generating the AMR datas
>>>>>
>>>> with a audio silence.
>>>>
>>>>> - Check if we can timestamps correctly the AMR
>>>>>
>>>> packets in the MP4/3GP hinted file.
>>>>
>>>>
>
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-video mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-video
>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Fri May 09, 2008 6:24 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi Sergio, Hi @All,
I think the solution that introduced by me works fine on none error prone channels.
In case of errors or lost frames the patch will not have any impact. I
understand that the adaption layer 2 for audio (AL2) and layer 3 for video (AL3)
of H.324M can be used with optional sequence numbers (SN). By using sequence
numbers, the receiver can detect lost frames.
But the use of SN is optional and depends on the implementation of the H.324M
stack on the mobile phone. If the phone doesn't support SN's we can't retrieve
lost frames.
In terms of the problem here with desynchronized audio/video or different
lengths of audio/video, I guess we could solve it only on phones that supports
sequence numbers.
Am I right?
Best regards,
Sven
Sergio Garcia Murillo wrote:
Quote:
Yes, please, if anyone test it, send the results to the list so we can
commit the patch to the repository.
A priori I see it quite clea, so I think it won't do any harm at all
(another issue is if it solves the problem :)
BR
Sergio
Sven Brandau escribió:
> Hi @All,
>
> recording to the questions, I've send you my patch.
>
> Please note that the patch is NOT really tested - please try it
> and send me your results.
>
> Patch it with (R213):
> patch -i app_h324m.c.patch
>
> Regards,
> Sven
>
>
>
>
> Sergio Garcia Murillo wrote:
>> Hi Sven
>>
>> Could you send me a patch with oyour solution?
>>
>> BR
>> Sergio
>>
>> ----- Original Message -----
>> From: Sven Brandau [mailto:brandau@gmx.de]
>> To: asterisk-video@lists.digium.com
>> Sent: Mon, 05 May 2008 15:30:33 +0200
>> Subject: Re: [Asterisk-video] mp4save(): different audio and video
>> lengths
>>
>> Hi @All,
>>
>> I'm working on a solution.
>>
>> I've found that some mobile phones (Moto K3) sending out AMR No-Data
>> packets, instead of comfort noise frames (AMR-SID). So I replaced the
>> No-Data packets with the last received AMR-SID frame (file app_h324m.c /
>> function create_ast_frame). This solution worked fine for me.
>>
>> The only thing is, that the recording for audio and video starts on a
>> different time - audio and video is already not synchronized, but only
>> a few milliseconds. It depends on the mp4save option /V - waiting for
>> the
>> first I-frame.
>>
>> I'm already working on this issue and will announce my solution here
>> on the
>> mailing list.
>>
>> Regards,
>> Sven
>>
>> Low Yu Siang wrote:
>>> Hi,
>>>
>>> May I know if anyone has solved the recording
>>> audio/video length problem?
>>>
>>> Tech from i6net wrote :
>>>> Hi,
>>>>
>>>> I am going to work on it.
>>>>
>>>> But for the moment, I am qualifying the video transcoder and the
>>>> h324m module.
>>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>>> locks after some secondes or minutes if it use the
>>> transcoder.
>>>> 2 ways for the recording :
>>>> - Replace the silence by generating the AMR datas
>>> with a audio silence.
>>>> - Check if we can timestamps correctly the AMR
>>> packets in the MP4/3GP hinted file.
>>>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Fri May 09, 2008 7:09 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Hi Sven,
As I said I think that the patch is correct and I hope to apply it soon.
I'd like to get some feedback first from the people that have reported
the problem so we all now the impact of the solution and if it solves
defenetivelly the problem.
About AL2,3 an SN.. you made me have to investigate my own code and
recover my h223 spec from the bottom of one of my drawers.. jeje.. I
finished that part of the code a year ago, so IIRC I used AL2 with SN
for both audio and video.
I'll have to take a deeper look and see how did I solved the problem of
dropped packets in app_mp4 as this would not only apply to h234m, you
could have the same issue in RTP. The solution is to specify the
timestamp of the amr packet in the asterisk sample strutcture, this
would probably mean to store the received amr frame until we receive the
next to know how much delay it's between both so we behave the same as
it's been done in RTP. Then app_mp4 would calculate the audio frame
timestamp according to that and solve the issue. I'll check how much of
this is actually implemented.
About aduo/video different lengths, it's normal.. first audio is sent at
20 ms intervals and video is sent at 1/fps (for 10fps is each 100ms).
Second audio is shorted and arrives first than video, so you could have
up two frames of difference in length (200ms). If there is more
difference will have to take a deeper look at it.
Best regards
Sergio
Sven Brandau escribió:
Quote:
Hi Sergio, Hi @All,
I think the solution that introduced by me works fine on none error
prone channels.
In case of errors or lost frames the patch will not have any impact. I
understand that the adaption layer 2 for audio (AL2) and layer 3 for
video (AL3) of H.324M can be used with optional sequence numbers (SN).
By using sequence numbers, the receiver can detect lost frames.
But the use of SN is optional and depends on the implementation of the
H.324M stack on the mobile phone. If the phone doesn't support SN's we
can't retrieve lost frames.
In terms of the problem here with desynchronized audio/video or
different lengths of audio/video, I guess we could solve it only on
phones that supports sequence numbers.
Am I right?
Best regards,
Sven
Sergio Garcia Murillo wrote:
> Yes, please, if anyone test it, send the results to the list so we
> can commit the patch to the repository.
> A priori I see it quite clea, so I think it won't do any harm at all
> (another issue is if it solves the problem :)
>
> BR
> Sergio
>
> Sven Brandau escribió:
>> Hi @All,
>>
>> recording to the questions, I've send you my patch.
>>
>> Please note that the patch is NOT really tested - please try it
>> and send me your results.
>>
>> Patch it with (R213):
>> patch -i app_h324m.c.patch
>>
>> Regards,
>> Sven
>>
>>
>>
>>
>> Sergio Garcia Murillo wrote:
>>> Hi Sven
>>>
>>> Could you send me a patch with oyour solution?
>>>
>>> BR
>>> Sergio
>>>
>>> ----- Original Message -----
>>> From: Sven Brandau [mailto:brandau@gmx.de]
>>> To: asterisk-video@lists.digium.com
>>> Sent: Mon, 05 May 2008 15:30:33 +0200
>>> Subject: Re: [Asterisk-video] mp4save(): different audio and video
>>> lengths
>>>
>>> Hi @All,
>>>
>>> I'm working on a solution.
>>>
>>> I've found that some mobile phones (Moto K3) sending out AMR No-Data
>>> packets, instead of comfort noise frames (AMR-SID). So I replaced the
>>> No-Data packets with the last received AMR-SID frame (file
>>> app_h324m.c /
>>> function create_ast_frame). This solution worked fine for me.
>>>
>>> The only thing is, that the recording for audio and video starts on a
>>> different time - audio and video is already not synchronized, but only
>>> a few milliseconds. It depends on the mp4save option /V - waiting
>>> for the
>>> first I-frame.
>>>
>>> I'm already working on this issue and will announce my solution
>>> here on the
>>> mailing list.
>>>
>>> Regards,
>>> Sven
>>>
>>> Low Yu Siang wrote:
>>>> Hi,
>>>>
>>>> May I know if anyone has solved the recording
>>>> audio/video length problem?
>>>>
>>>> Tech from i6net wrote :
>>>>> Hi,
>>>>>
>>>>> I am going to work on it.
>>>>>
>>>>> But for the moment, I am qualifying the video transcoder and the
>>>>> h324m module.
>>>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>>>> locks after some secondes or minutes if it use the
>>>> transcoder.
>>>>> 2 ways for the recording :
>>>>> - Replace the silence by generating the AMR datas
>>>> with a audio silence.
>>>>> - Check if we can timestamps correctly the AMR
>>>> packets in the MP4/3GP hinted file.
>>>>
>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Fri May 09, 2008 8:07 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
Sorry, Sergio,
My packaging script have overwritten the full sources (of the original
sources).
I have made the corrections and I have generated a new package with the
sources tagged modified.
It will be on line in few minutes.
Sorry for this inconvenience.
Tech from i6net
Sergio Garcia Murillo a écrit :
Quote:
Borja, remove the binary package from your web site or publish the
full source with the modifications please.
Best regards
Sergio
Borja SIXTO escribió:
> I have tested it.
> Is seems to works too.
> I think here a short delay (between the voice and the video) if I
> reprompt the message recorded.
>
> I have updated the binary package in the www.i6net.com website
> (select modified modules to install the app_h324m with the patch).
>
> You can test it in live here (with the Video VoiceXML call2web) :
> - By calling to : +34912104506 (spanish number)
> - And seeing the result here too :
> http://quartus.i6net.org/vxml/recorder/messages/index-i6net.html
>
> Regards,
>
>
> Tech from i6net
>
>
> Sergio Garcia Murillo a écrit :
>> Yes, please, if anyone test it, send the results to the list so we
>> can commit the patch to the repository.
>> A priori I see it quite clea, so I think it won't do any harm at all
>> (another issue is if it solves the problem :)
>>
>> BR
>> Sergio
>>
>> Sven Brandau escribió:
>>
>>> Hi @All,
>>>
>>> recording to the questions, I've send you my patch.
>>>
>>> Please note that the patch is NOT really tested - please try it
>>> and send me your results.
>>>
>>> Patch it with (R213):
>>> patch -i app_h324m.c.patch
>>>
>>> Regards,
>>> Sven
>>>
>>>
>>>
>>>
>>> Sergio Garcia Murillo wrote:
>>>
>>>> Hi Sven
>>>>
>>>> Could you send me a patch with oyour solution?
>>>>
>>>> BR
>>>> Sergio
>>>>
>>>> ----- Original Message -----
>>>> From: Sven Brandau [mailto:brandau@gmx.de]
>>>> To: asterisk-video@lists.digium.com
>>>> Sent: Mon, 05 May 2008 15:30:33 +0200
>>>> Subject: Re: [Asterisk-video] mp4save(): different audio and video
>>>> lengths
>>>>
>>>> Hi @All,
>>>>
>>>> I'm working on a solution.
>>>>
>>>> I've found that some mobile phones (Moto K3) sending out AMR No-Data
>>>> packets, instead of comfort noise frames (AMR-SID). So I replaced the
>>>> No-Data packets with the last received AMR-SID frame (file
>>>> app_h324m.c /
>>>> function create_ast_frame). This solution worked fine for me.
>>>>
>>>> The only thing is, that the recording for audio and video starts on a
>>>> different time - audio and video is already not synchronized, but
>>>> only
>>>> a few milliseconds. It depends on the mp4save option /V - waiting
>>>> for the
>>>> first I-frame.
>>>>
>>>> I'm already working on this issue and will announce my solution
>>>> here on the
>>>> mailing list.
>>>>
>>>> Regards,
>>>> Sven
>>>>
>>>> Low Yu Siang wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> May I know if anyone has solved the recording
>>>>> audio/video length problem?
>>>>>
>>>>> Tech from i6net wrote :
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am going to work on it.
>>>>>>
>>>>>> But for the moment, I am qualifying the video transcoder and the
>>>>>> h324m module.
>>>>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>>>>>>
>>>>> locks after some secondes or minutes if it use the
>>>>> transcoder.
>>>>>
>>>>>> 2 ways for the recording :
>>>>>> - Replace the silence by generating the AMR datas
>>>>>>
>>>>> with a audio silence.
>>>>>
>>>>>> - Check if we can timestamps correctly the AMR
>>>>>>
>>>>> packets in the MP4/3GP hinted file.
>>>>>
>>>>>
>>
>>
>>
>> _______________________________________________
>> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>>
>> asterisk-video mailing list
>> To UNSUBSCRIBE or update options visit:
>> http://lists.digium.com/mailman/listinfo/asterisk-video
>>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Fri May 09, 2008 8:40 pm Post subject: [Asterisk-video] mp4save(): different audio and video length
The new full package is on line now.
2 ways to install the Fonteventa applications :
- Original sources from the sip.fonteventa.com website (svn), without
modifications.
- Modified versions (modifications pending, testing or not approved for
the moment).
The installation script ask you the select one of this options.
The modifications delivered are :
- app_mp4 and app_rtsp, specific modifications to handle the DTMF
bargein (I am waiting to the modification proposed in the ticket list)
and the speech (ASR) streaming processing during the video playing (send
the audio packets to the Asterisk speech API, if the result is
available, the prompt is skipped).
- app_h324m, with the modification proposed by Sven and the ALAW forced
for European use. This week I will propose a configuration file
(h324m.conf) to parameter : G711 law, debug level and for the future to
add more initial parameters : I will propose this modification to the
ticket list too.
I will add a short text description about this modifications in the next
package.
Thanks Sergio for the feedback.
Regards,
Tech from i6net
Borja SIXTO a écrit :
Quote:
Sorry, Sergio,
My packaging script have overwritten the full sources (of the original
sources).
I have made the corrections and I have generated a new package with the
sources tagged modified.
It will be on line in few minutes.
Sorry for this inconvenience.
Tech from i6net
Sergio Garcia Murillo a écrit :
> Borja, remove the binary package from your web site or publish the
> full source with the modifications please.
>
> Best regards
> Sergio
>
> Borja SIXTO escribió:
>
>> I have tested it.
>> Is seems to works too.
>> I think here a short delay (between the voice and the video) if I
>> reprompt the message recorded.
>>
>> I have updated the binary package in the www.i6net.com website
>> (select modified modules to install the app_h324m with the patch).
>>
>> You can test it in live here (with the Video VoiceXML call2web) :
>> - By calling to : +34912104506 (spanish number)
>> - And seeing the result here too :
>> http://quartus.i6net.org/vxml/recorder/messages/index-i6net.html
>>
>> Regards,
>>
>>
>> Tech from i6net
>>
>>
>> Sergio Garcia Murillo a écrit :
>>
>>> Yes, please, if anyone test it, send the results to the list so we
>>> can commit the patch to the repository.
>>> A priori I see it quite clea, so I think it won't do any harm at all
>>> (another issue is if it solves the problem :)
>>>
>>> BR
>>> Sergio
>>>
>>> Sven Brandau escribió:
>>>
>>>
>>>> Hi @All,
>>>>
>>>> recording to the questions, I've send you my patch.
>>>>
>>>> Please note that the patch is NOT really tested - please try it
>>>> and send me your results.
>>>>
>>>> Patch it with (R213):
>>>> patch -i app_h324m.c.patch
>>>>
>>>> Regards,
>>>> Sven
>>>>
>>>>
>>>>
>>>>
>>>> Sergio Garcia Murillo wrote:
>>>>
>>>>
>>>>> Hi Sven
>>>>>
>>>>> Could you send me a patch with oyour solution?
>>>>>
>>>>> BR
>>>>> Sergio
>>>>>
>>>>> ----- Original Message -----
>>>>> From: Sven Brandau [mailto:brandau@gmx.de]
>>>>> To: asterisk-video@lists.digium.com
>>>>> Sent: Mon, 05 May 2008 15:30:33 +0200
>>>>> Subject: Re: [Asterisk-video] mp4save(): different audio and video
>>>>> lengths
>>>>>
>>>>> Hi @All,
>>>>>
>>>>> I'm working on a solution.
>>>>>
>>>>> I've found that some mobile phones (Moto K3) sending out AMR No-Data
>>>>> packets, instead of comfort noise frames (AMR-SID). So I replaced the
>>>>> No-Data packets with the last received AMR-SID frame (file
>>>>> app_h324m.c /
>>>>> function create_ast_frame). This solution worked fine for me.
>>>>>
>>>>> The only thing is, that the recording for audio and video starts on a
>>>>> different time - audio and video is already not synchronized, but
>>>>> only
>>>>> a few milliseconds. It depends on the mp4save option /V - waiting
>>>>> for the
>>>>> first I-frame.
>>>>>
>>>>> I'm already working on this issue and will announce my solution
>>>>> here on the
>>>>> mailing list.
>>>>>
>>>>> Regards,
>>>>> Sven
>>>>>
>>>>> Low Yu Siang wrote:
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> May I know if anyone has solved the recording
>>>>>> audio/video length problem?
>>>>>>
>>>>>> Tech from i6net wrote :
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am going to work on it.
>>>>>>>
>>>>>>> But for the moment, I am qualifying the video transcoder and the
>>>>>>> h324m module.
>>>>>>> The Gateway (SIP -> 3G or 3G -> SIP) configuration
>>>>>>>
>>>>>>>
>>>>>> locks after some secondes or minutes if it use the
>>>>>> transcoder.
>>>>>>
>>>>>>
>>>>>>> 2 ways for the recording :
>>>>>>> - Replace the silence by generating the AMR datas
>>>>>>>
>>>>>>>
>>>>>> with a audio silence.
>>>>>>
>>>>>>
>>>>>>> - Check if we can timestamps correctly the AMR
>>>>>>>
>>>>>>>
>>>>>> packets in the MP4/3GP hinted file.
>>>>>>
>>>>>>
>>>>>>
>>>
>>> _______________________________________________
>>> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>
>>> asterisk-video mailing list
>>> To UNSUBSCRIBE or update options visit:
>>> http://lists.digium.com/mailman/listinfo/asterisk-video
>>>
>>>
>
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum