2014-04-30 23:22:15 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#ifndef MEDIA_FILE_UDP_FILE_H_
|
|
|
|
#define MEDIA_FILE_UDP_FILE_H_
|
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2014-04-30 23:22:15 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/compiler_specific.h"
|
|
|
|
#include "packager/media/file/file.h"
|
2014-04-30 23:22:15 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2014-04-30 23:22:15 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
/// Implements UdpFile, which receives UDP unicast and multicast streams.
|
|
|
|
class UdpFile : public File {
|
|
|
|
public:
|
|
|
|
/// @param file_name C string containing the address of the stream to receive.
|
|
|
|
/// It should be of the form "<ip_address>:<port>".
|
|
|
|
explicit UdpFile(const char* address_and_port);
|
|
|
|
|
|
|
|
/// @name File implementation overrides.
|
|
|
|
/// @{
|
2015-07-22 23:40:45 +00:00
|
|
|
bool Close() override;
|
|
|
|
int64_t Read(void* buffer, uint64_t length) override;
|
|
|
|
int64_t Write(const void* buffer, uint64_t length) override;
|
|
|
|
int64_t Size() override;
|
|
|
|
bool Flush() override;
|
|
|
|
bool Seek(uint64_t position) override;
|
|
|
|
bool Tell(uint64_t* position) override;
|
2014-04-30 23:22:15 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
protected:
|
2015-07-22 23:40:45 +00:00
|
|
|
~UdpFile() override;
|
2014-04-30 23:22:15 +00:00
|
|
|
|
2015-07-22 23:40:45 +00:00
|
|
|
bool Open() override;
|
2014-04-30 23:22:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int socket_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(UdpFile);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-04-30 23:22:15 +00:00
|
|
|
|
|
|
|
#endif // MEDIA_FILE_UDP_FILE_H_
|