Diego
Compile the plugins using _STATIC_LINK option for both G.722 and H.264 this will create static libraries and #define H323_STATIC_H264 and H323_STATIC_G7221 in openh323buildopts.h.in to load them.
Simon
From: h323plus-bounces@lists.packetizer.com [mailto:h323plus-bounces@lists.packetizer.com] On Behalf Of Diego Carvalho
Sent: 01 May 2012 05:39
To: Simon Horne; h323plus@lists.packetizer.com
Subject: Re: [h323plus] H323-SIP Gateway with H264 Support
Hi Simon,
I am very grateful for the version of the H264 plugin with the _SGINAL_ONLY option. After using it I finally could make video work on my application.
Now I have 2 more challenges:
1 - Link the H264 and G722 plugins statically. How can I do this?
2 - I still have problems with capability negotiation. You said me to override H323Connection::OnSetLocalCapabilities to remove the codecs that SIP doesn't support. But this function is called in the very beginning of a call, when I don't have SIP info yet. So I answer the call with H323Connection::AnswerCallPending and then start the SIP call. So I will have the SIP info only before sending the Connect PDU (e.g before calling H323Connection::AnswerCallNow). Is there another way to modify the local capabilities with this constraint?
I appreciate any help. Thanks in advance.
2012/4/10 Simon Horne <s.horne@packetizer.com>
Diego
Today I checked into the CVS a compile directive _SIGNAL_ONLY which will compile the plugin without dependencies on FFMPEG or X264. You only need h264-x264.h/.cxx. You can use this in conjunction with _STATIC_LINK to build a static library to statically link the codec into the h323plus library.
http://h323plus.cvs.sourceforge.net/viewvc/h323plus/h323plus/plugins/video/H.264/
You will need to configure the makefile.in with these switches (not done yet)
Also G.722 has serious interop issues. Mainly due to IMHO an error in the RFC. Although the codec is a 16k codec the RTP timestamps are incremented as 8k in the RFC. On the H.323 side they almost always use a 16k timestamp while on the SIP side it’s mostly 8k.
Simon
From: h323plus-bounces@lists.packetizer.com [mailto:h323plus-bounces@lists.packetizer.com] On Behalf Of Diego Carvalho
Sent: 10 April 2012 04:41
To: h323plus@lists.packetizer.com
Subject: Re: [h323plus] H323-SIP Gateway with H264 Support
Hi Simon, thanks a lot for you help, but I will have to bother you again. Now I could compile the H264 plugin after remove the code you told me but I couldn't make my program load it. I tried 3 different things: first I put the .so and the help in the same folder as my app, second I tried to install the plugins in the default folder (/usr/local/lib/opal-1.24.0/) and finally I tried to set PWLIBPLUGINDIR. None of these worked. I also tried to load the G722 plugin and at least this one should work because I didn't change it. Am I missing something?
I also tried to enable the stack's log. At first glance, it didn't show anything about plugins. Then I used the following code, from Simple app:
PDirectory DefaultDir = PProcess::Current().GetFile().GetDirectory();
PPluginManager & pluginMgr = PPluginManager::GetPluginManager();
pluginMgr.LoadPluginDirectory(DefaultDir);
This makes the app loads the plugins from the current directory. After this the log shows:
2012/04/09 11:08:17.701 4 pluginmgr.cxx(96) PLUGIN Enumerating plugin directory /home/diego/H323Gateway/bin/Debug/
2012/04/09 11:08:17.701 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/g722_audio_pwplugin.so against suffix _ptplugin
2012/04/09 11:08:17.701 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/g722_audio_pwplugin.so against suffix _pwplugin
2012/04/09 11:08:17.702 3 h323pluginmgr.cxx(2529) H323PLUGIN Loading plugin codec g722_audio_pwplugin
2012/04/09 11:08:17.702 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/h264_video_pwplugin_helper against suffix _ptplugin
2012/04/09 11:08:17.702 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/h264_video_pwplugin_helper against suffix _pwplugin
2012/04/09 11:08:17.702 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/h264_video_pwplugin.so against suffix _ptplugin
2012/04/09 11:08:17.702 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/h264_video_pwplugin.so against suffix _pwplugin
2012/04/09 11:08:18.053 3 h323pluginmgr.cxx(2525) H323PLUGIN Plugin Codec DLL h264_video_pwplugin contains no codec definitions
2012/04/09 11:08:18.058 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/H323Gateway against suffix _ptplugin
2012/04/09 11:08:18.058 5 pluginmgr.cxx(106) PLUGIN Checking /home/diego/H323Gateway/bin/Debug/H323Gateway against suffix _pwplugin
So it seems that it loaded G722 correctly and encontered an error while loading H264. But when the app starts, there is no G722 on capabilities table. I also tried to use the G722 plugin in the Simple app and got the same result. The app shows this in its start up:
Codecs (in preference order):
Table:
G.711-ALaw-64k <1>
G.711-uLaw-64k <2>
UserInput/hookflash <3>
UserInput/basicString <4>
UserInput/dtmf <5>
UserInput/RFC2833 <6>
UserInput/Navigation <7>
UserInput/Softkey <8>
UserInput/PointDevice <9>
UserInput/Modal <10>
So, no G722.
A last thing is how to link the plugins statically. You said something about the CVS. Does it mean that the option to load the plugins statically is not available in the current version (1.24.0)?
Thanks in advance.
2012/4/3 Simon Horne <s.horne@packetizer.com>
Diego
There are 2 functions to load the plugin.
PLUGIN_CODEC_IMPLEMENT(H264)
PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version)
These are left as they are (including all the macro associated with them)
All Encryption/Decryption is handled by the H264Encoder/H264Decoder classes. Simple remove these classes and everything referenced by the classes.
Where they are instanced.
static void * create_encoder(const struct PluginCodec_Definition * /*codec*/)
static void * create_decoder(const struct PluginCodec_Definition * /*codec*/)
return NULL.
That’s it. It should compile without needing FFMPEG or X264.
Simon
From: h323plus-bounces@lists.packetizer.com [mailto:h323plus-bounces@lists.packetizer.com] On Behalf Of Diego Carvalho
Sent: 04 April 2012 03:57
To: h323plus@lists.packetizer.com
Subject: Re: [h323plus] H323-SIP Gateway with H264 Support
Hi Simon.
Again, I would like to thank you because you helped me to solve two problems: make SIP and H323 endpoints exchange media directly and set capabilities by call basis. Actually, the code you showed me didn't work in my tests (remove all capabilities and then add the ones I want) but I could at least remove the capabilities I don't want. Anyway, now my last big problem is the H264 support. I'm totally lost. You said: "Simply supply the codec definitions and the codec will be available in h323plus. ". But supply where? I don't know where to define the PluginCodec_Definition or the other things you mentioned. Since I'm not an expert on H264 (I know enough to make things work, lol) I would like to use what is already done, I mean, is it possible to make some changes in the H264 plugin to make it work only for signaling or I need to make something from the scratch? Regardless the answer, give me some instructions, please. Thanks in advance.
2012/3/27 Simon Horne <s.horne@packetizer.com>
Diego
Sorry for delay in replying
With Reference to the document you linked to
The plugin codec exports 2 functions for capability registration
unsigned int PWLibPlugin_GetAPIVersion()
PluginCodec_Definition * OpalCodecPlugin_GetCodecs(unsigned * count, unsigned version)
The OpalCodecPlugin_GetCodecs function returns all the information you need on the signaling side. Simply supply the codec definitions and the codec will be available in h323plus.
You DO NOT need to create the Codec Methods which link to FFMPEG/x264.
For only supplying the codecs you need rather than removing them for the call. Clone the Capability List then remove all the orginal and add back the ones you want.
In your derived
void H323Connection::OnSetLocalCapabilities()
H323Capabilities * myCapabilities(localCapabilities);
localCapabilities.RemoveAll();
H323Capability * cap = myCapabilities.FindCapability(“H.264*”);
If (cap)
LocalCapabilities.Add(cap);
Simon
From: Diego Carvalho [mailto:diego.cdomingos2010@gmail.com]
Sent: 28 March 2012 06:37
To: Simon Horne
Subject: [h323plus] H323-SIP Gateway with H264 Support
Hi Simon, thanks for answering again. Today I could establish SIP -> H323 audio calls. So now I only need to deal with the 2 points below.
I'm really interested in being able to add H.264 in the capability set without having to link the library with FFMPEG/X264, but I couldn't understand what you explained. I searched on the internet and found this: http://www.voxgratia.org/docs/codec_plugins.html
that I believe is related to what you explained but even with this page I couldn't realize what I have to do. Is it possible to configure the plugin that comes with the source in this way? I mean, use the plugin in h323plus/plugin/video/H.264 for only signaling, without have to link with FFMPEG/X264.
Another question is again about the capabilities. You said that I can remove the capabilities that aren't supported by the SIP endpoint. But this way, I will have to add all possible capabilities to my gateway and them remove the ones that SIP doesn't support. It would be much easier if my gateway could start without any capabilities and then I add the ones that SIP supports. Is that possible? If not, I will have to do what you explained but when I will add all the capabilities again to be ready to handle the next call?
Again, thanks for all the help.
2012/3/23 Simon Horne <s.horne@packetizer.com>
Diego
There is some issues with changes in FFMPEG v54 and a number of function names changed and others were depreciated recommend v52. I am currently working through issues with v54. Again X264 is a moving target but last I looked it compiled on Linux. On Windows is a whole different story unfortunately.
If you are only using the codec for signaling there should be no need to link to either FFMPEG or X264 and you can gut the plugins and only define the PluginCodec_Definitions, Plugin_Codec_Implementation() and PLUGIN_CODEC_GET_CODEC_FN. These are the signaling parts of the codec. The Encoder/Decoder contexts can be removed. There is some changes in the CVS to also allow you to load these plugins statically see the openh323buildopt.h.in.
To filter capabilities on a call by call basis you can do this by overriding H323Capabilities::OnSetLocalCapabilities() and use the localCapabilities.Remove() function to remove the capabilities not used on the SIP side.
Simon
From: h323plus-bounces@lists.packetizer.com [mailto:h323plus-bounces@lists.packetizer.com] On Behalf Of Diego Carvalho
Sent: 23 March 2012 22:44
To: h323plus@lists.packetizer.com
Subject: Re: [h323plus] H323-SIP Gateway with H264 Support
Hi Simon and "chr_cb". First of all, thanks for your help. Today I was able to establish an audio only call between H323 and SIP using the gateway I'm developing. This is great but I still have some problems and I appreciate any help on this:
1) Like I said, it was an audio only call. I was able to compile the plugins with the packages from Ubuntu repositories (libx264-dev, libavcodec-dev and libavutil-dev) but my project also uses ffmpeg and x264 so I would like to compile with the latest source code from git we use. The config.log shows some errors and on the internet I saw somebody saying that only a specific version of ffmpeg allows the compilation. Is that true? If so, what would be the version of ffmpeg and x264 I should use? Again, I would like to reiterate that I only want to have H264 on my capabilities list (I don't want to capture/render video). Do I indeed need the plugin? Is there another way?
2) If I set the gateway capabilities in the beginning it works but I want so set them in a later time. Specifically, I receive the call and send an invite on hold to SIP. Then it will answer with 200 OK with SDP. In this moment, when I have the SIP SDP, I want to set the gateway capabilities based on what the SIP side supports. How can I do this? If I try to add in this moment it simply doesn't add them.
Thanks in advance.
2012/3/13 Simon Horne <s.horne@packetizer.com>
Diego
The plugins load default capability instances into the H323Endpoint.
When the H323Connection is created these capabilities are cloned
In H323Connection::OnSetLocalCapabilities()
Simply remove the unmatched capabilities
localCapabilities.Remove("H.264*");
The H323_ExternalRTPChannel does not handle RTP but can be used to not use
the internal RTP system. You can have your own external RTP stack or not
have one at all.
You needed to read and populate H245_H2250LogicalChannelParameters in the
send and receive message of the class with those of the SIP Client.
I do have serious doubts what you are planning will work not because it
can't technically work but because of the differences in H.323 and SIP with
Video. H.323 is very strict on rules while SIP is very loose on
interpretations.
Here are the problems
1. RTP packetization H.323 says strictly single NAL SIP is undefined 2
options (Single NAL/Fragmented units) . You will get video on the H.323 side
just fine but your SIP side with some devices may not be able to decode.
2. Payload Type for H.264 is specified as being flexible but a lot of SIP
implementations have them fixed (usually 96 or 97) so H.323 requests 103
SIP always ends 97 no video on the H.323 side. There is no way you can fix
this with signaling as SIP tells the other party what it is going to send
and H.323 tells the party what it wants to receive. You have to proxy the
media to fix the payload type number.
Good luck.
Simon
============================================================================
=============================================
From: Diego Carvalho [mailto:diego.cdomingos2010@gmail.com]
Sent: 14 March 2012 06:09
To: Simon Horne
Subject: Re: [h323plus] H323-SIP Gateway with H264 Support
Hi Simon, thanks for answering but I still have some doubts:
You said that this plugin will add the capability automatically. Actually,
as I said, I'm building a H323-SIP gateway so, for instance, when the SIP
endpoint is making a call I want to add the H264 capability only if the SIP
endpoint offers it. Will I be able to add the capability manually? For
instance, using localCapabilities.Add(new H323_H264Capability()). To
sumarize, I want to be able to add (or remove if it was automatically added
and the current call does not offer it) manualy the H264 capability.
Also I don't know if the H323_ExternalRTPChannel applies to my situation.
It's used to pass the RTP to another device. I don't want to handle the RTP
at all (to be clear: I don't want RTP arriving on the gateway's network
card). I want to send to h323 the RTP address/port SIP offered and
vice-versa, so the RTP will flow directly between the endpoints. Any
thoughts? Thanks in advance.
2012/3/13 Simon Horne <s.horne@packetizer.com>
Diego
H.264 is a video plugin in the plugin/video directory. You will need X264
and FFMPEG. For Ubuntu they are libx264-dev libavcodec-dev and
libavutil-dev.
You build the plugin .so and the helper (in the gpl subdirectory) and place
them both in the same directory as you app. The application will load them
at startup and automatically add the capability to the capabilityset etc
If you don’t want to use the plugin for RTP then have a look at the
H323_ExternalRTPChannel. This will bypass the RTP handling in the codec to
whatever you want.
http://www.voxgratia.org/docs/external_rtp.html
(its from 2004 but still current)
Simon
From: h323plus-bounces@lists.packetizer.com
[mailto:h323plus-bounces@lists.packetizer.com] On Behalf Of Diego Carvalho
Sent: 14 March 2012 03:05
To: h323plus@lists.packetizer.com
Subject: [h323plus] H323-SIP Gateway with H264 Support
Hi all,
I'm working on a h323-sip gateway with video (H264) support and I'm facing
some problems. I'm new with H323plus and with h323 protocol itself (I'm
learning as I go) so excuse me if I say something stupid.
First of all, I believe that the stack can be used to build a gateway but it
seems that it's more focused on terminals. Am I right? So is it possible or
not to build a gateway using it?
Second, there is no native support for H264. The documentation shows the
class hierarchy. For audio we have, for instance, H323Cabability ->
H323RealTimeCapability -> H323AudioCapability -> H323_G711Cabability but we
don't have H323Cabability -> H323RealTimeCapability -> H323VideoCapability
-> H323_H264Cabability. I tried to create this one, extending from
H323Cabability -> H323RealTimeCapability -> H323VideoCapability ->
H323GenericVideoCabability and then I discovered that I would need to
override a function called CreateCodec to return a codec that handles the
video. But I don't want to handle the RTP media. I just want to put H264 in
the terminal capability set and establish a connection in a way that the
H323 and SIP terminals can exchange the media directly. I've heard about a
H264 plugin but it seems that it is for handling the media, so I don't know
if it fits my purpose. How can I achieve this? Is there any plan to support
H264 natively on H323plus? Also I need to get the remote RTP port. The only
way I found to do this is trough H323Connection::OnStartLocicalChannel but
this is called after a channel to handle the data is created and again, I
don't want to handle the RTP data. I appreciate any help. Thanks.