Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
udp_file.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILE_UDP_FILE_H_
8 #define MEDIA_FILE_UDP_FILE_H_
9 
10 #include <stdint.h>
11 
12 #include <string>
13 
14 #include "packager/base/compiler_specific.h"
15 #include "packager/file/file.h"
16 
17 #if defined(OS_WIN)
18 #include <winsock2.h>
19 #else
20 typedef int SOCKET;
21 #endif // defined(OS_WIN)
22 
23 namespace shaka {
24 
26 class UdpFile : public File {
27  public:
30  explicit UdpFile(const char* address_and_port);
31 
34  bool Close() override;
35  int64_t Read(void* buffer, uint64_t length) override;
36  int64_t Write(const void* buffer, uint64_t length) override;
37  int64_t Size() override;
38  bool Flush() override;
39  bool Seek(uint64_t position) override;
40  bool Tell(uint64_t* position) override;
42 
43  protected:
44  ~UdpFile() override;
45 
46  bool Open() override;
47 
48  private:
49  SOCKET socket_;
50 
51  DISALLOW_COPY_AND_ASSIGN(UdpFile);
52 };
53 
54 } // namespace shaka
55 
56 #endif // MEDIA_FILE_UDP_FILE_H_
int64_t Read(void *buffer, uint64_t length) override
Definition: udp_file.cc:61
bool Tell(uint64_t *position) override
Definition: udp_file.cc:100
bool Seek(uint64_t position) override
Definition: udp_file.cc:95
UdpFile(const char *address_and_port)
Definition: udp_file.cc:47
Define an abstract file interface.
Definition: file.h:26
int64_t Write(const void *buffer, uint64_t length) override
Definition: udp_file.cc:78
Implements UdpFile, which receives UDP unicast and multicast streams.
Definition: udp_file.h:26
bool Close() override
Definition: udp_file.cc:52
bool Open() override
Internal open. Should not be used directly.
Definition: udp_file.cc:148
int64_t Size() override
Definition: udp_file.cc:83
bool Flush() override
Definition: udp_file.cc:90