libflute
FileDeliveryTable.h
Go to the documentation of this file.
1 // libflute - FLUTE/ALC library
2 //
3 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
4 // 2025 British Broadcasting Corporation (David Waring <david.waring2@bbc.co.uk>)
5 //
6 // Licensed under the License terms and conditions for use, reproduction, and
7 // distribution of 5G-MAG software (the “License”). You may not use this file
8 // except in compliance with the License. You may obtain a copy of the License at
9 // https://www.5g-mag.com/reference-tools. Unless required by applicable law or
10 // agreed to in writing, software distributed under the License is distributed on
11 // an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 // or implied.
13 //
14 // See the License for the specific language governing permissions and limitations
15 // under the License.
16 //
17 #pragma once
18 #include <stddef.h>
19 #include <stdint.h>
20 #include <optional>
21 #include <string>
22 #include <vector>
23 #include "flute_types.h"
24 
25 namespace LibFlute {
30  public:
34  enum FdtNamespace {
38 // FDT_NS_RFC6726, // FLUTE v2 - will need other things implementing to use this correctly
40  };
41 
49  FileDeliveryTable(uint32_t instance_id, FecOti fec_oti, FdtNamespace fdt_namespace = FDT_NS_NONE);
50 
58  FileDeliveryTable(uint32_t instance_id, char* buffer, size_t len);
59 
63  virtual ~FileDeliveryTable() {};
64 
68  uint32_t instance_id() { return _instance_id; };
69 
73  struct FileEntry {
74  uint32_t toi;
75  std::string content_location;
76  uint32_t content_length;
77  std::string content_md5;
78  std::string content_type;
79  uint64_t expires;
81  struct {
82  bool no_cache;
83  std::optional<uint64_t> cache_expires;
85  std::string content_encoding;
86  std::string etag;
87 
88  bool operator==(const FileEntry &other) const;
89  bool operator!=(const FileEntry &other) const { return !(*this == other); };
90  };
91 
95  void set_expires(uint64_t exp) { _expires = exp; };
96 
100  void add(const FileEntry& entry);
101 
105  void remove(uint32_t toi);
106 
110  std::string to_string() const;
111 
115  const std::vector<FileEntry> &file_entries() const {
116  return _file_entries;
117  };
118 
122  void sent() { _instance_id_sent = _instance_id; };
123 
124  private:
125  uint32_t _instance_id;
126  uint32_t _instance_id_sent;
127 
128  std::vector<FileEntry> _file_entries;
129  FecOti _global_fec_oti;
130 
131  uint64_t _expires;
132 
133  FdtNamespace _fdt_namespace;
134  };
135 };
A class for parsing and creating FLUTE FDTs (File Delivery Tables).
FdtNamespace
FDT namespace enumeration.
const std::vector< FileEntry > & file_entries() const
Get all current file entries.
virtual ~FileDeliveryTable()
Default destructor.
uint32_t instance_id()
Get the FDT instance ID.
void remove(uint32_t toi)
Remove a file entry.
std::string to_string() const
Serialize the FDT to an XML string.
void add(const FileEntry &entry)
Add a file entry.
void sent()
Mark instance sent.
FileDeliveryTable(uint32_t instance_id, FecOti fec_oti, FdtNamespace fdt_namespace=FDT_NS_NONE)
Create an empty FDT.
void set_expires(uint64_t exp)
Set the expiry value.
OTI values struct.
Definition: flute_types.h:51
An entry for a file in the FDT.
std::optional< uint64_t > cache_expires
bool operator!=(const FileEntry &other) const
struct LibFlute::FileDeliveryTable::FileEntry::@0 cache_control
bool operator==(const FileEntry &other) const