[Mplayer-cvslog] CVS: main/libmpdemux netstream.h,1.1,1.2 stream_netstream.c,1.1,1.2
Alban Bedel CVS
albeu at mplayerhq.hu
Sun Apr 6 20:16:13 CEST 2003
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv21041/libmpdemux
Modified Files:
netstream.h stream_netstream.c
Log Message:
It should now be endian aware. Untested as i only have le box :(
Would be cool if someone with a be,le network could test.
Index: netstream.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/netstream.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- netstream.h 6 Apr 2003 16:33:13 -0000 1.1
+++ netstream.h 6 Apr 2003 18:15:43 -0000 1.2
@@ -3,6 +3,8 @@
* Common stuff for netstream
* Packets and so on are defined here along with a few helpers
* wich are used by both the client and the server
+ *
+ * Data is always low endian
*/
typedef struct mp_net_stream_packet_st {
@@ -64,7 +66,8 @@
free(pack);
return NULL;
}
-
+ pack->len = le2me_16(pack->len);
+
if(pack->len < sizeof(mp_net_stream_packet_t)) {
mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid packet (too small: %d)\n",pack->len);
free(pack);
@@ -113,10 +116,19 @@
pack->cmd = cmd;
// printf("Write packet %d %d (%p) %d\n",fd,cmd,data,len);
+ pack->len = le2me_16(pack->len);
if(net_write(fd,(char*)pack,pack->len)) {
free(pack);
return 1;
}
free(pack);
return 0;
+}
+
+static void net_stream_opened_2_me(mp_net_stream_opened_t* o) {
+ o->file_format = le2me_32(o->file_format);
+ o->flags = le2me_32(o->flags);
+ o->sector_size = le2me_32(o->sector_size);
+ o->start_pos = le2me_64(o->start_pos);
+ o->end_pos = le2me_64(o->end_pos);
}
Index: stream_netstream.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream_netstream.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- stream_netstream.c 6 Apr 2003 16:33:13 -0000 1.1
+++ stream_netstream.c 6 Apr 2003 18:15:43 -0000 1.2
@@ -57,6 +57,7 @@
#include "help_mp.h"
#include "../m_option.h"
#include "../m_struct.h"
+#include "../bswap.h"
#include "netstream.h"
@@ -158,7 +159,7 @@
}
static int fill_buffer(stream_t *s, char* buffer, int max_len){
- uint16_t len = max_len;
+ uint16_t len = le2me_16(max_len);
mp_net_stream_packet_t* pack;
pack = send_net_stream_cmd(s,NET_STREAM_FILL_BUFFER,(char*)&len,2);
@@ -179,7 +180,7 @@
static int seek(stream_t *s,off_t newpos) {
- uint64_t pos = (uint64_t)newpos;
+ uint64_t pos = le2me_64((uint64_t)newpos);
mp_net_stream_packet_t* pack;
pack = send_net_stream_cmd(s,NET_STREAM_SEEK,(char*)&pos,8);
@@ -259,6 +260,8 @@
}
opened = (mp_net_stream_opened_t*)pack->data;
+ net_stream_opened_2_me(opened);
+
*file_format = opened->file_format;
stream->flags = opened->flags;
stream->sector_size = opened->sector_size;
More information about the MPlayer-cvslog
mailing list