DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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/media/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 namespace media {
25 
27 class UdpFile : public File {
28  public:
31  explicit UdpFile(const char* address_and_port);
32 
35  bool Close() override;
36  int64_t Read(void* buffer, uint64_t length) override;
37  int64_t Write(const void* buffer, uint64_t length) override;
38  int64_t Size() override;
39  bool Flush() override;
40  bool Seek(uint64_t position) override;
41  bool Tell(uint64_t* position) override;
43 
44  protected:
45  ~UdpFile() override;
46 
47  bool Open() override;
48 
49  private:
50  SOCKET socket_;
51 
52  DISALLOW_COPY_AND_ASSIGN(UdpFile);
53 };
54 
55 } // namespace media
56 } // namespace shaka
57 
58 #endif // MEDIA_FILE_UDP_FILE_H_
bool Open() override
Internal open. Should not be used directly.
Definition: udp_file.cc:140
int64_t Write(const void *buffer, uint64_t length) override
Definition: udp_file.cc:70
Implements UdpFile, which receives UDP unicast and multicast streams.
Definition: udp_file.h:27
Define an abstract file interface.
Definition: file.h:24
int64_t Read(void *buffer, uint64_t length) override
Definition: udp_file.cc:53
bool Tell(uint64_t *position) override
Definition: udp_file.cc:92
bool Flush() override
Definition: udp_file.cc:82
UdpFile(const char *address_and_port)
Definition: udp_file.cc:38
bool Seek(uint64_t position) override
Definition: udp_file.cc:87
bool Close() override
Definition: udp_file.cc:44
int64_t Size() override
Definition: udp_file.cc:75