当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 4 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 请问有这样一个后缀为.c的程序,我要如何安到系统中?
帖子发表于 : 2007-04-06 22:46 

注册: 2007-03-24 15:27
帖子: 60
送出感谢: 0 次
接收感谢: 0 次
这是那个文件的源码

/*****************************************************************************
* nscdec.c: NSC decoder 1.0
*****************************************************************************
* Copyright (C) 2005 Jon Lech Johansen <jon@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/

#include <stdio.h>
#include <ctype.h>
#include <iconv.h>
#include <string.h>
#include <stdlib.h>

static const unsigned char inverse[ 128 ] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
0x3B, 0x3C, 0x3D, 0x3E, 0xFF, 0x3F, 0xFF, 0xFF
};

static int load_byte( unsigned char encoding_type,
unsigned char *output, char **input,
unsigned char *j, unsigned char *k )
{
*output = 0;

if( encoding_type == 1 )
{
if( isxdigit( **input ) == 0 )
return -1;

if( isdigit( **input ) == 0 )
*output = (toupper( **input ) - 7) * 16;
else
*output = **input * 16;

(*input)++;

if( isxdigit( **input ) == 0 )
return -1;

if( isdigit( **input ) == 0 )
*output |= toupper( **input ) - 0x37;
else
*output |= **input - 0x30;

(*input)++;
}
else if( encoding_type == 2 )
{
unsigned char **uinput = (unsigned char **)input;

if( **uinput > 127 || inverse[ **uinput ] == 0xFF )
return -1;

if( *k == 0 )
{
if( (*uinput)[ 1 ] > 127 || inverse[ (*uinput)[ 1 ] ] == 0xFF )
return -1;

*output = (inverse[ (*uinput)[ 0 ] ] * 4) |
(inverse[ (*uinput)[ 1 ] ] / 16);

*j = inverse[ (*uinput)[ 1 ] ] * 16;
*k = 4;

(*uinput) += 2;
}
else if( *k == 2 )
{
*output = *j | inverse[ **uinput ];

*j = 0;
*k = 0;

(*uinput)++;
}
else if( *k == 4 )
{
*output = (inverse[ **uinput ] / 4) | *j;

*j = inverse[ **uinput ] * 64;
*k = 2;

(*uinput)++;
}
}

return 0;
}

int main( int argc, char **argv )
{
int ret = 0;

unsigned int i;
unsigned char tmp;
unsigned char j, k;
unsigned int length;
unsigned char encoding_type;
unsigned char *buffer;

if( argc != 2 )
{
fprintf( stderr, "Usage: nscdec string\n" );
return 1;
}

char *p_input = &argv[ 1 ][ 0 ];

if( strlen( p_input ) < 15 )
{
fprintf( stderr, "Input string less than 15 characters\n" );
return 1;
}

if( load_byte( 1, &encoding_type, &p_input, NULL, NULL ) )
{
fprintf( stderr, "Unable to get encoding type\n" );
return 1;
}

if( encoding_type != 1 && encoding_type != 2 )
{
fprintf( stderr, "Encoding type %d is not supported\n",
encoding_type );
return 1;
}

printf( "Encoding type: %d\n", encoding_type );

j = k = 0;

if( load_byte( encoding_type, &tmp, &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
return 1;
}

for( i = 0; i < 4; i++ )
{
if( load_byte( encoding_type, &tmp, &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
return 1;
}
}

length = 0;
for( i = 4; i; i-- )
{
if( load_byte( encoding_type, &tmp, &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
return 1;
}
length |= tmp << ((i - 1) * 8);
}

if( length == 0 )
{
fprintf( stderr, "Length is 0\n" );
return 1;
}

buffer = (unsigned char *)malloc( length );
if( buffer == NULL )
{
fprintf( stderr, "Out of memory\n" );
return 1;
}

for( i = 0; i < length; i++ )
{
if( load_byte( encoding_type, &buffer[ i ], &p_input, &j, &k ) )
{
fprintf( stderr, "load_byte failed\n" );
free( (void *)buffer );
return 1;
}
}

if( buffer[ length - 1 ] != 0 && buffer[ length - 2 ] != 0 )
{
printf( "Decoded data:\n" );
for( i = 0; i < length; i++ )
{
printf( "0x%02X, ", buffer[ i ] );
if( ((i + 1) % 12) == 0 )
printf( "\n" );
}
printf( "\n" );
}
else
{
iconv_t conv;

char *buf8;
char *p_buf8;
char *p_buffer;
size_t buffer_size = length;
size_t buf8_size = length;

buf8 = (char *)malloc( buf8_size + 1 );
if( buf8 == NULL )
{
fprintf( stderr, "Out of memory\n" );
free( (void *)buffer );
return 1;
}

conv = iconv_open( "UTF-8", "UTF-16LE" );
if( conv == (iconv_t)-1 )
{
fprintf( stderr, "iconv_open failed\n" );
free( (void *)buffer );
free( (void *)buf8 );
return 1;
}

p_buf8 = &buf8[ 0 ];
p_buffer = (char *)&buffer[ 0 ];

if( iconv( conv, &p_buffer, &buffer_size,
&p_buf8, &buf8_size ) == -1 )
{
fprintf( stderr, "iconv failed\n" );
ret = 1;
}
else
{
buf8[ length - buf8_size ] = 0;
printf( "Decoded string: [%s]\n", buf8 );
}

iconv_close( conv );

free( (void *)buf8 );
}

free( (void *)buffer );

return ret;
}

据说有了这个就能播放后缀为nsc的在线电视,但我不知道该 如何用它,请问我该怎么做?


页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2007-04-06 22:50 
头像

注册: 2006-12-29 20:13
帖子: 694
送出感谢: 0 次
接收感谢: 0 次
引用:
据说有了这个就能播放后缀为nsc的在线电视,但我不知道该 如何用它,请问我该怎么做?
据谁说的你就去问谁。[/code]


_________________
在学习linux的道路上自在而行。


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2007-04-06 22:51 
头像

注册: 2006-09-02 14:18
帖子: 5308
地址: 汉桑城
送出感谢: 1
接收感谢: 1
fallleaf 写道:
引用:
据说有了这个就能播放后缀为nsc的在线电视,但我不知道该 如何用它,请问我该怎么做?
据谁说的你就去问谁。
说的....
呵呵


_________________
全世界linux爱好者联合起来 !
一切闭源操作系统都是纸老虎 !
要斗私批修,拒绝黑屏,使用linux !
让一部分人先用起Archlinux来 !
linux是第一生产力 !
讲正气,讲开源,讲free
要坚定不移的走开源的道路 !
linux明天会更好 !

dpkg -l |grep ^rc|awk '{print $2}' |tr ["\n"] [" "]|sudo xargs dpkg -P -
ubuntu粉丝群 26660836 已满员


页首
 用户资料  
 
4 楼 
 文章标题 :
帖子发表于 : 2007-04-06 23:35 

注册: 2007-03-24 15:27
帖子: 60
送出感谢: 0 次
接收感谢: 0 次
呵呵,人家是外国人,我英文水平不够,问不了!!!!!!!!!!!!

是这样的,在一个外国人的论坛上,有人问如何播放后缀为.nsc的流媒体在线电视,呵呵,我也遇到了同样的问题,我们学校也是用的这种格式的在线电视,那个人提问的原文如下,
Hi.

Someone knows how to play asx/nsc stream?

I'm able to play many kinds of stream, but when I try to
play:

mplayer -playlist http://www.radiopopolare.it/live.asx

the buffering starts and reachs an "end of file" after 4188
bytes, that is the dimension of the .nsc file invoked by the
playlist.
The output is:

Playing http://www.radiopopolare.it/live.nsc.
Resolving www.radiopopolare.it for AF_INET...
Connecting to server
www.radiopopolare.it[195.110.125.146]:80 ...
Cache size set to 320 KBytes
Connected to server: www.radiopopolare.it
Cache fill: 1.28% (4188 bytes)

Exiting... (End of file)

The same happens invokind directly the .nsc file.

It could be a codec problem? Someone have a suggestion?
I use mplayer1.0pre4.

Thanks
Lucio

,原文地址为:http://lists.mplayerhq.hu/pipermail/mplayer-users/2004-June/046356.html

然后看到有一个人回帖说,
Please add nsc playlist support to mplayer.

NSC has been hacked by Jon Lech Johansen (The man
behind PyMusique and SharpMusique)

Jons Blog:
"I’ve reverse engineered the encoding used in
the Microsoft NSC format and written a decoder."

http://nanocrew.net/?m=200508


NSC decoder:
http://nanocrew.net/software/nscdec.c

Implementation for VLC:
http://nanocrew.net/software/libvc1-1.0.tar.gz
http://nanocrew.net/software/vlc-libvc1.diff

best regards

Per

大致意思就是说只要将nsc播放列表的支持加入到mplayer里就可以了!nsc的文件已经被一个人破解了,
http://nanocrew.net/?m=200508
这个网址是那个人的博客。我到那个人的博客去一看,它大致意思上就是让下载一个nscdec.c的文件,就是我在楼顶上的那个文件,然后它还写出了一个example usage:
$ nscdec 02AW000000000SLm1D0580HG1C0440MG0m0380800i0200GG0000
Encoding type: 2
Decoded string: [WMRELAY02 , A]
仅此而己。
但我想了半天也想不明白应如何来用它。
我试着用 gcc编译了一下,生成一个a.out的文件,我试着运行了./a.out,显示
floyd@floyd-laptop:~/Desktop$ ./a.out
Usage: nscdec string
我试着运行./a.out http://210.28.16.73/iptv-1.nsc
出现了
floyd@floyd-laptop:~/Desktop$ ./a.out http://210.28.16.73/iptv-1.nsc
Unable to get encoding type
至此,我再也不知道该怎么办了!

请高手一定要帮我啊!!!!!!!!!!!


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 4 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:Google [Bot] 和 4 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译