Using libmms with Objective-C

I've been looking for a few days around the internet for tutorials or examples on how to use libmms. There seems to be none, which is strange for a lib thats seems to be widely used.

LibMMS is a common library for parsing mms:// and mmsh:// type network streams. http://sourceforge.net/projects/libmms/files/libmms/0.6.2/libmms-0.6.2.tar.gz/download

The only code sample I found was from another post on stackoverflow.

Which is will show below.

mms_connect(NULL, NULL, g_tcUrl.av_val, g_hostname.av_val, g_playpath.av_val, "", g_port, 128*1024)

Note:

NSString* strTemp;      
strTemp = @"mms://123.30.49.85/htv2";
// strTemp = @"mms://212.58.251.92/wms/bbc_ami/radio1/radio1_bb_live_int_eq1_sl0";
g_tcUrl.av_val = new char[[strTemp length] + 1];
[strTemp getCString:g_tcUrl.av_val
          maxLength:([strTemp length]+1)
           encoding:NSUTF8StringEncoding];
g_tcUrl.av_len = strlen(g_tcUrl.av_val);
//strTemp = @"212.58.251.92";
strTemp = @"123.30.49.85";
g_hostname.av_val = new char[[strTemp length]+1];       
[strTemp getCString:g_hostname.av_val
          maxLength:([strTemp length]+1)
           encoding:NSUTF8StringEncoding];
g_hostname.av_len = strlen(g_hostname.av_val);
//strTemp = @"/wms/bbc_ami/radio1/radio1_bb_live_int_eq1_sl0";
strTemp = @"/htv2";
g_playpath.av_val = new char[[strTemp length] + 1];         
[strTemp getCString:g_playpath.av_val
          maxLength:([strTemp length]+1)
           encoding:NSUTF8StringEncoding];
g_playpath.av_len = strlen(g_playpath.av_val);
g_port = 1755; 

This is not objective C, but does show what needs to be passed into the mms_connect method.

So i made a new project, included all the needed libmms files and built it. Compiled ok.

The next step was to include the

#import "mms.h"
#import "mms_config.h"

and declare

mms_t *mms = 0;

No problems so far.

Next thing i wanted to try was to call the mms_connect method and here is where i get stuck.

I'm not a C programmer so this might look FUBAR but was my best attempt. I cannot use the

char *g_tcUrl = new char[[strTemp length] + 1];

because new is not recognized in objective c in the way its used here. What should I be using to achieve the same effect in Objective-C?

mms_t *mms = 0;

NSString* strTemp;      
strTemp = @"mms://123.30.49.85/htv2";

char *g_tcUrl = new char[[strTemp length] + 1];
[strTemp getCString:g_tcUrl maxLength:([strTemp length]+1) 
encoding:NSUTF8StringEncoding];

strTemp = @"123.30.49.85";
char *g_hostname = new char[[strTemp length]+1];       
[strTemp getCString:g_hostname maxLength:([strTemp length]+1) 
encoding:NSUTF8StringEncoding];

strTemp = @"/htv2";
char * g_playpath = new char[[strTemp length] + 1];         
[strTemp getCString:g_playpath maxLength:([strTemp length]+1) 
encoding:NSUTF8StringEncoding];
int g_port = 1755;

//mms = mms_connect(mms_io_t *io, void *data, const char *url, const char *host, 
const char *uri, const char *query, int port, int bandwidth);
mms = mms_connect(NULL, NULL, g_tcUrl, g_hostname, g_playpath, "", g_port, 
128*1024);

Now I'm trying to mix in C code inside objective-c files. That code was all inside my viewDidLoad as I try and test and figure out how exactly to use libmms.

Guys I'd appreciate all advise and help you can offer in my quest to get libmms working in my app.

-Code

6
задан Bo Persson 2 June 2011 в 20:13
поделиться