Statistics
| Revision:

svn-gvsig-desktop / branches / v05 / libraries / libjni-ecw / include / NCSJPCEcwpIOStream.h @ 40081

History | View | Annotate | Download (3.88 KB)

1 3538 nacho
/********************************************************
2
** Copyright 2002 Earth Resource Mapping Ltd.
3
** This document contains proprietary source code of
4
** Earth Resource Mapping Ltd, and can only be used under
5
** one of the three licenses as described in the
6
** license.txt file supplied with this distribution.
7
** See separate license.txt file for license details
8
** and conditions.
9
**
10
** This software is covered by US patent #6,442,298,
11
** #6,102,897 and #6,633,688.  Rights to use these patents
12
** is included in the license agreements.
13
**
14
** FILE:     $Archive: /NCS/Source/include/NCSJP2IOStream.h $
15
** CREATED:  28/11/2002 3:27:34 PM
16
** AUTHOR:   Simon Cope
17
** PURPOSE:  CNCSJPCIOStream class header
18
** EDITS:    [xx] ddMmmyy NAME COMMENTS
19
 *******************************************************/
20
21
#ifndef NCSJPCECWPIOSTREAM_H
22
#define NCSJPCECWPIOSTREAM_H
23
24
#ifndef NCSJPCMEMORYIOSTREAM_H
25
#include "NCSJPCMemoryIOStream.h"
26
#endif // NCSJPCMEMORYIOSTREAM_H
27
#ifndef NCSJPCPRECINCT_H
28
#include "NCSJPCPrecinct.h"
29
#endif // NCSJPCPRECINCT_H
30
#ifndef NCSUTIL_H
31
#include "NCSUtil.h"
32
#endif // NCSUTIL_H
33
34
#include "NCScnet.h"
35
36
/**
37
 * CNCSJPCEcwpIOStream class - 64bit ECWP IO "Stream" class.
38
 * This class is the IO mechanism used to access JP2 files via ECWP.
39
 * << and >> Operators are not implemented as we can't use exception handling for portability reasons.
40
 *
41
 * @author       Simon Cope
42
 * @version      $Revision$ $Author$ $Date$
43
 */
44
class NCSJPC_EXPORT_ALL CNCSJPCEcwpIOStream: public CNCSJPCMemoryIOStream, private CNCSMutex {
45
public:
46
47
        class NCSJPC_EXPORT_ALL CNCSJPCPacketStatus {
48
        public:
49
                /** Packet status enum */
50
                typedef enum {
51
                        NONE                = 0,
52
                        REQUESTED,
53
                        RECEIVED,
54
                        DECODED
55
                } Status;
56
57
                NCSJPCPacketId        m_nPacket;
58
                Status                        m_eStatus;
59
        };
60
        typedef std::map<NCSJPCPacketId, CNCSJPCPacketStatus>::iterator CNCSJPCPacketStatusIterator;
61
62
                /** Constructor, initialises members */
63
        CNCSJPCEcwpIOStream(CNCSJPC *pJPC, bool bSeekable = true);
64
                /** Virtual destructor, releases members */
65
        virtual ~CNCSJPCEcwpIOStream();
66
67
        virtual void Lock(bool bLockJPC = true);
68
        virtual void UnLock(bool bUnLockJPC = true);
69
                /**
70
                 * Open the stream on the specified file.
71
                 * @param                pEcwpURL                ECWP URL
72
                 * @return      CNCSError        NCS_SUCCESS, or error code on failure.
73
                 */
74
        virtual CNCSError Open(char *pEcwpURL);
75
                /**
76
                 * Close the stream.
77
                 * @return      CNCSError        NCS_SUCCESS, or error code on failure.
78
                 */
79
        virtual CNCSError Close();
80
81
                /** Is the stream a packet stream?  This means the SOD segment will be missing from
82
                 * the stream as parsed, and must be requested separately (ie, ECWP, JPIP)
83
                 * @return                bool                true this is a packet stream, otherwise false
84
                 */
85
        virtual bool NCS_FASTCALL IsPacketStream();
86
87
        virtual void RequestPrecinct(CNCSJPCPrecinct *pPrecinct);
88
        virtual void CancelPrecinct(CNCSJPCPrecinct *pPrecinct);
89
        virtual CNCSError SendRequests();
90
91
        virtual CNCSJPCPacketStatus::Status GetPacketStatus(NCSJPCPacketId nPacket);
92
        virtual void SetPacketStatus(NCSJPCPacketId nPacket, CNCSJPCPacketStatus::Status eStatus);
93
94
        virtual void ProcessReceivedPackets();
95
protected:
96
        CNCSJPC                        *m_pJPC;
97
        pNCSnetClient        m_ClientNetID;
98
        NCSClientUID        m_ClientUID;
99
        bool                        m_bIsConnected;
100
        bool                        m_bSendInProgress;
101
        NCSSequenceNr        m_nClientSequence;
102
        NCSPacket                *m_pSendPacket;
103
104
        std::map<NCSJPCPacketId, CNCSJPCPacketStatus> m_Packets;
105
106
        typedef struct {
107
                NCSPacket *pPacket;
108
                INT32 nLength;
109
        } ReceivedPacket;
110
        std::list<ReceivedPacket*> m_ReceivedPackets;
111
112
                /** Precincts we need to request packets for */
113
        std::vector<CNCSJPCPrecinct*> m_RequestPrecincts;
114
                /** Precincts we need to cancel packets for */
115
        std::vector<CNCSJPCPrecinct*> m_CancelPrecincts;
116
117
        static void PacketRecvCB(NCSPacket *pPacket, INT32 nLength, pNCSnetClient pClientNetID, CNCSJPCEcwpIOStream *pJPC, NCSError eError);
118
        static void PacketSentCB(NCSError eError, UINT8 *pLastPacketSent, CNCSJPCEcwpIOStream *pJPC);
119
};
120
121
#endif // !NCSJPCECWPIOSTREAM_H