AVPKit
URLProtocolHandler.h
1 /*******************************************************************************
2  * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved.
3  *
4  * This file is part of AVPKit.
5  *
6  * AVPKit is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * AVPKit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with AVPKit. If not, see <http://www.gnu.org/licenses/>.
18  *******************************************************************************/
19 
20 #ifndef URLPROTOCOLHANDLER_H_
21 #define URLPROTOCOLHANDLER_H_
22 
23 #include <stdint.h>
24 
25 #include <com/avpkit/core/io/IO.h>
26 
27 #include <com/avpkit/core/io/URLProtocolHandlerFactory.h>
28 
29 namespace com { namespace avpkit { namespace core { namespace io
30 {
31  class URLProtocolHandlerFactory;
32  class VS_API_AVPKIT_IO URLProtocolHandler
33  {
34  public:
35  typedef enum SeekFlags {
36  SK_SEEK_SET=0,
37  SK_SEEK_CUR=1,
38  SK_SEEK_END=2,
39  SK_SEEK_SIZE=0x10000,
40  } SeekFlags;
41  typedef enum OpenFlags {
42  URL_RDONLY_MODE=1,
43  URL_WRONLY_MODE=2,
44  URL_RDWR_MODE=3,
45  } OpenFlags;
46 
47  typedef enum SeekableFlags {
48  SK_NOT_SEEKABLE =0x00000000,
49  SK_SEEKABLE_NORMAL=0x00000001,
50  } SeekableFlags;
51  virtual ~URLProtocolHandler();
52  virtual const char* getProtocolName();
53  virtual URLProtocolHandlerFactory *getProtocolManager() { return mManager; }
54 
55  // Now, let's have our forwarding functions
56  virtual int url_open(const char *url, int flags)=0;
57  virtual int url_close()=0;
58  virtual int url_read(unsigned char* buf, int size)=0;
59  virtual int url_write(const unsigned char* buf, int size)=0;
60  virtual int64_t url_seek(int64_t position, int whence)=0;
61  virtual SeekableFlags url_seekflags(const char* url, int flags)=0;
62 
63  protected:
66 
67  private:
68  URLProtocolHandlerFactory* mManager;
69  };
70 }}}}
71 #endif /*URLPROTOCOLHANDLER_H_*/
A class for managing custom io protocols.
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...