Software
Software Architecture
In most cases, the ATHEN-IPEYE serves as an server, which
provides the service of converting analog Video and Audio signals into MPEG4 and
ADPCM stream data and sending it to clients via Ethernet. To achieve this, the
ATHEN-IPEYE uses not only hardware, but also layers of software. This section is devoted
to an introduction to the software layers of the ATHEN-IPEYE.
Server AP
File System
Embedded Linux OS Kernel
Driver
Client AP
ActiveX Controls
Windows
Bootloader
ATHEN-IPEYE Hardware
UDP socket protocols
ATHEN-IP
EYE
Ethernet
Client
Bootloader: this layer of software is closest to the hardware. It helps to:
1. Setup SDRAM and PXA255 registers
2. Activate and configure all ICs on ATHEN-IPEYE
3. Load (the) OS kernel and File system into SDRAM
4. Pass execution to (the) OS
Please refer to the bootloader section for further information.
Embedded Linux OS kernel, Driver and File system: ATHEN-IPEYE uses a
2.4.19
Linux kernel. Please refer to the embedded Linux section
for further information.
Server AP: The ATHEN-IPEYE is equipped with a server AP. This AP realizes the
socket protocols defined in later sections so that the user can design his client
AP
22
based on these protocols. Please refer to the UDP Packet Format section for
detailed information. The source code of the server AP is also provided for
advanced users to develop their own AP. In this case, the
ATHEN-IPEYE ’s originally defined socket protocols become invalid, and the
user may define his own protocol. Of course, the ActiveX controls
provide together with ATHEN-IPEYE is useless if use define a different
socket protocol.
UDP socket protocols: Define the communication between client and server using
the UDP socket
ActiveX Controls: Three Windows ActiveX controls are available for the user to
develop his client AP. These 3 controls implement socket protocols defined in
the UDP Packet Format section. Because it is the server AP that implement
these protocols, the ATHEN-IPEYE must run the original server AP provided
with the ATHEN-IPEYE .
Flash Partitions
All ATHEN-IPEYE server software reside in a 16Mb flash device, and each has its
fixed position and range. The position and range are defined by the bootloader and the
user should not change them without consulting designer.
Bootloader: 0x00000000 ~ 0x0003FFFF
OS kernel: 0x00040000 ~ 0x0013FFFF
File System: 0x00140000 ~ 0x00DFFFFF (jffs2)
User AP space: 0x00E00000 ~ 0x00FFFFFF (jffs2)
23
Bootloader
The Bootloader is in charge of the following things
— Configuring on board ICs and Registers of PXA-255
— Linux kernel booting service
— Other services, including
„ Kernel and file system download: download, tftp
„ Writing downloaded images into Flash: fwrite
„ Mac address configuration: mac
„ Ethernet IP configure: ifconfig
„ Help for commands: help
To enter bootloader, use an RS232 COM port and a null modem cable to link to the
ATHENE ’s Full UART (COM1 port). Press the ‘enter’ key before the OS kernel boots.
The default setting for bootloader on the Full UART (COM1 port) is “115200”,”8”,”n”,”1”,
no hardware handshake.
Download Kernel and file system (with) “download” command
blob> help download
Help for 'download':
Usage: download {blob|param|kernel|ramdisk}
Download
image to RAM using uuencode
(to download kernel)
blob> download kernel
You have 60 seconds to start downloading.
(to download root file system)
blob> download ramdisk
You have 60 seconds to start downloading.
** Remember to uuencode images before download.
Download Kernel and file system with “tftp” command
blob> help tftp
Help for 'tftp':
Usage: tftp file-name ram-addr
(to tftp kernel)
blob> tftp zImage0803.jffs2 0xa0200000
downloading zImage0803.jffs2 to 0xa0200000
.....................done
blob>
(to tftp root file system)
blob> tftp ATHENE fs0804.img 0xa0400000
downloading ATHENE fs0804.img to 0xa0400000
................................................................................
................................................................................
................................................................................
................................................................................
......done
blob>
** In order to use ‘tftp’, the user needs to setup a linux server site with IP specified as in
‘ifconfig’, ‘server ip’, and also activate tftp service on it.
Writing downloaded image into Flash: fwrite
blob> help fwrite
Help for 'fwrite':
Usage: fwrite srcadr destadr size(bytes)
flash a memory region
(to fwrite kernel)
blob> fwrite 0xa0200000 0x00040000 900000
Erasing 7 blocks at 0x00040000:.......done
Flashing 0x000dbba0 bytes at 0x00040000:.......done
blob>
(to fwrite root file system)
blob> fwrite 0xa0400000 0x00140000 13369344
Erasing 102 blocks at 0x00140000:.......done Flashing
0x00cc0000 bytes at 0x00140000:.......done blob>
** Before fwrite, user should ‘download’ or ‘tftp’ images into RAM first.
25
Mac address configuration: mac
blob> help mac
Help for 'mac':
Usage: mac aabbccddeeff
(show current mac address)
blob> mac
Mac addr : 12:34:12:34:12:34
blob>
(assign new mac address)
blob> mac 112233445566
Erasing 1 blocks at 0x00020000:.done
Saving Environment to Flash...Erasing 1 blocks
at
0x00020000:.done
Flashing 0x00000006 bytes at 0x00020000:.done
done.
blob> mac
Mac addr : 11:22:33:44:55:66
blob>
** Change to mac address is permanent.
Ethernet IP configure: ifconfig
blob> help ifconfig
Help for 'ifconfig':
Usage: ifconfig [ip|mac|server] addr
blob>
(show current ifconfig setting)
blob> ifconfig
Mac addr : 11.22.33.44.55.66
Our IP addr : 192.168.0.218
Server IP addr : 192.168.0.71
blob>
(assign new ifconfig setting)
blob> ifconfig ip 192.168.0.70
blob> ifconfig
Mac addr : 11.22.33.44.55.66
Our IP addr : 192.168.0.70
Server IP addr : 192.168.0.71
blob>
** Change to ifconfig is not permanent, after reset if becomes default setting.
Our IP addr : 192.168.0.218
Server IP addr : 192.168.0.71
26
Help for commands: help
‘help’ is used to list all commands under bootloader with a description of how each is
used.
blob> help
The following commands are supported:
* reset
* reboot
* boot
* download
* go
* xdownload
* flash
* speed
* status
* reload
* reblob
* fwrite
* ferase
* tftp
* ifconfig
* mac
* help
Use "help command" to get help on a specific command
blob>
27
Embedded Linux, Root File System and User AP
The ATHEN-IPEYE uses Linux kernel 2.4.19. This Linux kernel is patched so that it
can support the PXA-255 CPU. Please consult designer for any customization changes on
the Linux kernel.
[root@ATHENE bin]#uname -a
Linux ATHENE 2.4.19-rmk7-pxa1 #4 Tue Aug 3 14:42:50 CST
2004 armv5tel unknown
[root@ATHENE bin]#
The rootFS of ATHEN-IPEYE uses a jffs2 file system and contains many
functions. Here are some of important services that may be used frequently:
— tftp, ftp (client): Use these two services, user could do file transferring on
ATHEN-IPEYE
— telnet: Use this to provide console service through Ethernet.
— vi: Text file editor.
The User AP space in the ATHEN-IPEYE flash is mounted on ‘/ATHENE ’. It is in
this directory that server APs are installed.
[root@Athene IPEYE /]#df
Filesystem 1k-blocks Used Available Use%
Mounted on
/dev/mtdblock3 2048 704 1344
34% /Athene IPEYE
[root@ATHEN IPEYE /]#
Server AP
The server APs of the ATHEN-IPEYE consists of the following programs:
— IPEYE_server: This program is in charge of responding to the client’s inquiry.
(Socket port 8001,8002, 8004) It also in charge of WDT function.
— IPEYE_rplay: This program is in charge of Audio & Video processing and
transmitting.
(Socket port 8003)
— playwork: This program is in charge of MP3 decoding and audio output. (Socket port
8000)
Please refer to the following sections for more detailed operational descriptions of the
ATHEN-IPEYE server APs.
28
UDP Packet Format
This section describes packet contents used for communication between client PC and
the ATHEN-IPEYE .
- The communication between client and server uses UDP sockets.
- Every ATHEN-IPEYE has a unique IP address and the client must know its IP in
order to allocate the ATHEN-IPEYE
- Communications with different purposes use different socket port:
„ Client needs at least 3 ports:
¾ 1st port, used to send UDP packet to server port 8000 ~ 8002
¾ 2nd port(AV_LocalPort), used to receive MP4 video and ADPCM audio stream
data from server
¾ 3rd port(LocapPort), used to receive other response data from server
„ Server uses 5 ports:
¾ Port 8000: used to receive MP3 stream data from client that is linked to it
¾ Port 8001: used to receive a linking request from any client
¾ Port 8002: used to receive all other requests from client that is linked to it
¾ Port 8003: used to send MP4 video and ADPCM audio stream data to client
that is linked to it
¾ Port 8004: used to send response data to a client
Server Port: 8000 – To receive MP3 Frame Data from (a) client
The ATHEN-IPEYE uses socket port 8000 to receive MP3 frames from a client. The
packet data contents are described as following:
MP3 frame
Frame_SerialNumber Frame_Header Frame_Data
2 bytes 4 bytes
Frame_SerialNumber: 2 byte, 0x0000 ~ 0xFFFF
- Every next frame increases the SerialNumber by 1.
- After ‘0xFFFF’, the next frame takes 0x0000 as its serial number.
Frame_Header: 32 bit.
- Frame_Header contains standard MP3 Frame Header.
- Each frame has its own header
29
Frame_Data:
- These are compressed MP3 audio data
- 418 or 417 bytes
Programmers are responsible for the following issues:
¾ Every 26 ms, a new frame packet arrives at the server
¾ The client must link to the server before it starts to send MP3 frame packet.
¾ Unexpected problems may occur if a client sends a frame packet to a server that is
linked by another client.
Server Port: 8001 – To receive linking request from a client Linking
request is sent to the ATHEN-IPEYE at port 8001. Any client can send a linking
request packet to the server, whether the server is linked or not, and the server must
reply to the client at the client’s port. So, the client can also use this port to test whether a
server exists and/or if a server is free to link.
The linking request packet format (client to server)
Number of Bytes
4 2 2 1
1 1 1 1
Client IP
LocalPort
AV_LocalPort
CH_Enable
VideoMode
FrameRate
Quantization
IP_Interval
- ClientIP: Client IP address.
- LocalPort: Client local port number, to tell server which client port to send all
UDP packets, except AV stream data.
- AV_LocalPort: Client AV local port number, to tell server which client port to
send AV stream data.
„ If AV_LocalPort = 0, server will treat this request as linking status
checking only, no actual linking action processed.
„ If AV_LocalPort is not 0, server will process the linking request.
- CH_Enable: bit operation, 0: for disable, 1: for Enable (1 Byte)
„ bit 0: Video Channel 0 Enable/Disable
„ bit 1: Video Channel 1 Enable/Disable
„ bit 2: Video Channel 2 Enable/Disable
„ bit 3: Video Channel 3 Enable/Disable
30
„ bit 4: Audio Channel 0 Enable/Disable
„ bit 5: Audio Channel 1 Enable/Disable
„ bit 6: Audio Channel 2 Enable/Disable
„ bit 7: Audio Channel 3 Enable/Disable
- VideoMode: (1 Byte)
„ 0: NTSC Cif, 320 * 0
„ 1: NTSC Full, 640 * 480
„ 2: PAL CCIF, 352 * 288
„ 3: PAL Full, 702 * 576
- FrameRate: Video frame rate setting (1 Byte)
„ 0: 30 (NTSC) , 25 (PAL) frame/sec
„ 1: 15 (NTSC) , 12.5 (PAL) frame/sec
„ 2: 7.5 (NTSC) , 6.25 (PAL) frame/sec
„ 3: 3.75 (NTSC) , 3.125 (PAL) frame/sec
„ 4: 1.875 (NTSC) , 1.5625 (PAL) frame/sec
„ 5: 0.9375 (NTSC) , 0.78125 (PAL) frame/sec
- Quantization: Quant. value 1 ~ 31 (1 Byte)
- IP_Interval: (1 Byte)
„ 0: IP interval = 2
„ 1: IP interval = 4
„ 2: IP interval = 8
„ 3: IP interval = 16
„ 4: IP interval = 32
„ 5: IP interval = 64
„ 6: IP interval = 128
„ 7: IP interval = 256
Response packet format for linking request (server to client)
This response packet is received by a client at LocalPort defined in previous linking
request. The packet format is:
ServerIP LinkResult
4 bytes 1 bytes
- ServerIP: The server IP address (4 Byte)
- LinkResult: (1 Byte)
„ 0x00: Client Link successfully(AV_LocalPort is not 0), or client is
free for link(AV_LocalPort= 0)
„ 0xFF: AlreadyLinkedByCurrentClient
„ 0xFE: AlreadyLinkedByOtherClient
31
„ 0xFD: Error_WrongVideoMode (AV_LocalPort is not 0)
„ 0xFC: Error_WrongFrameRate (AV_LocalPort is not 0)
„ 0xFB: Error_WrongQuantization (AV_LocalPort is not 0)
„ 0xFA: Error_WrongVideoIPInterval (AV_LocalPort is not 0)
Server Port: 8002 – To receive operating request from a Client
The server receives all operation requests at this port. Only after server is linked, this
port became active, otherwise, no action is taken nor data responded to. The server
replies to the client at client LocalPort specified in previous linking request.
Request format (client to server)
Request_ID Data
1 bytes
Request_ID Requested Function Data Size
1 Checking current configuration 0 byte
2 Watch Dog Clear 0 byte
3 Configuration change request 5 bytes
4 Server reset request 0 byte
Checking current configuration:
- To check the current configuration, send a request with ID = 1. The server
replies with the current configurations to the client.
- Data content: Empty
Watch Dog Clear
- When a server receives a Watch Dog Clear request, it replies to the client.
- Once a server is linked by a particular client, the client must keep sending this
request port every second.
- If a server doesn’t receive any packet at this port after more than 5 seconds, a
hardware reset occurs using WDT.
- Data content: Empty
32
Configuration change request
- When a server receives a Configuration change request, it replies to (the)
client.
- Data:
CH_Enable
VideoMode
FrameRate
Quantization
IP_Interval
1 bytes
1 bytes
1 bytes 1 bytes 1 bytes
- CH_Enable: For the channel enable/disable setting, refer to previous sections
for value definition
- VideoMode: For the video mode setting, refer to previous sections for value
definition
- FrameRate: For the video frame rate setting, refer to previous sections for value
definition
- Quantization: Quant. value 1 ~ 31 (1 Byte)
- IP_Interval: For the video IP interval setting, refer to previous sections for value
definition
Server reset request
- When a server receives a Server reset request, it resets itself immediately
without a reply.
- Data content: Empty
The response packet format (server to client)
ServerIP
Request_ID Data
4 bytes
1 bytes
ServerIP: The server IP address (4 Byte)
Request_ID:
Request_ID Requested Function Data Size
1 Replying current configuration 5 bytes
2 Replying Watch Dog Clear 0 bytes
3 Result of Configuration change request 1 bytes
33
Replying current configuration
- When the server receives a current configuration checking request, it replies
to the client
- Data Contents:
CH_Enable
FrameMode
FrameRate
Quantization
IP_Interval
1 bytes 1 bytes 1 bytes
1 bytes 1 bytes
- CH_Enable: For channel enable/disable setting, refer to previous sections for
value definition
- FrameMode: For the video mode setting, refer to previous sections for value
definition
- FrameRate: For the video frame rate setting, refer to previous sections for value
definition
- Quantization: Quant. value 1 ~ 31 (1 Byte)
- IP_Interval: For the video IP interval setting, Please refer to previous sections for
value definition
Watch Dog Clear Replay
- When a server receives a Watch Dog Clear request, it replies to the client
- Data Contents: Empty
Result of Configuration Change Request
- When a server receives a Configuration Change Request, it replies to the
client
- Packet Content:
Result
- Result: (1
Byte)
1 bytes
„ 0x00: Configuration Changed successfully
„ 0xFE: AlreadyLinkedByOtherClient
„ 0xFD: Error_WrongVideoMode (AV_LocalPort is not 0)
„ 0xFC: Error_WrongFrameRate (AV_LocalPort is not 0)
„ 0xFB: Error_WrongQuantization (AV_LocalPort is not 0)
„ 0xFA: Error_WrongVideoIPInterval (AV_LocalPort is not 0)
34
Receiving MP4 Video and ADPCM Audio Stream from ATHEN-IPEYE
The server sends out an MP4 Video and ADPCM Audio data stream to the client’s
AV_LocalPort, which is told to server in the linking request. The pocket data contents are
described as following:
MajorType MinorType
Length
Data
1 bytes 1 bytes 2 bytes
MajorType: 1 byte
- Indicates the major type of packet data
- There are two major types:
„ SP_MEDIA (0xA0), packet data is header information
„ SP_DATA (0xD0), packet data is stream data
- When SP_MEDIA major type is received, PutHeader() method in ViewerCtrl
should be called to place header information.
- When SP_ DATA major type is received, PutData() method in ViewerCtrl
should be called to place stream data.
MinorType: 1 byte
- Indicates the following packet data is Video or Audio
- For SP_MEDIA major type, the MinorType defines that:
„ MinorType = MEDIA_VIDEO (0x01), packet data is Video header
information
„ MinorType = MEDIA_AUDIO (0x02), packet data is Audio header
information
- For SP_Data major type, the MinorType defines that:
„ MinorType = MEDIA_VIDEO (0x01), packet data is Mp4 Video frame
data
„ MinorType = MEDIA_AUDIO (0x02), packet data is ADPCM Audio
frame data
Length: 2 byte
- Identifies the length of Data, not including MajorType, MinorType and
Length itself.
- In byte unit.
Data:
- The Data contains header or stream data of compressed Mp4 Video or
ADPCM Audio
- Refer to the following table for data contents
35
MajorType MinorType Data
Byte 0 in Data: FrameWidth (2 byte)
MEDIA_VIDEO Byte 2 in Data: FrameHeight (2 byte)
Byte 4 in Data: 30 / FramePerSecond (1 byte)
SP_MEDIA
SP_DATA
MEDIA_AUDIO
MEDIA_VIDEO
MEDIA_AUDIO
Byte 0~3 in Data: SampleRate (4 Byte)
Byte 4~7 in Data: BitRate (4 Byte)
Byte 8 in Data: ChannelMode (1 byte), always = 2, for
ADPCM
Byte 0 in Data: Current Frame Number (1 byte)
Byte 1 in Data: Current packet count for current frame number
(1 byte)
Byte 2 in Data: Total packet count for current frame number (1
byte)
Bit 4~7 of Byte 3 in Data: Channel Number (4 bits)
Bit 0~3 of Byte 3 in Data: Video Key Frame (4 bits)
Byte 4 ~: Compressed Mp4 Video data ((Length – 4) byte)
Byte 0 in Data: Current Frame Number (4 byte)
Byte 1 in Data: Current packet count for current frame number
(1 byte)
Byte 2 in Data: Total packet count for current frame number (1
byte)
Bit 4~7 of Byte 3 in Data: Channel Number (4 bits)
Bit 0~3 of Byte 3 in Data: Reserved
Byte 4 ~: Compressed ADPCM Audio data ((Length – 4) byte)
36
ActiveX Controls
For further information, Please refer to:
ATHEN-IPEYE Client Site ActiveX Control Programming Guide
The ATHEN-IPEYE is shipped with three ActiveX Controls to support user’s AP
development on the client site. They are ViewerCtrl, MP3EncoderCtrl and ATHENE
LinkCtrl