Shaka Packager SDK
mock_mpd_builder.h
1 // Copyright 2015 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 MPD_BASE_MOCK_MPD_BUILDER_H_
8 #define MPD_BASE_MOCK_MPD_BUILDER_H_
9 
10 #include <gmock/gmock.h>
11 
12 #include "packager/base/compiler_specific.h"
13 #include "packager/base/synchronization/lock.h"
14 #include "packager/mpd/base/adaptation_set.h"
15 #include "packager/mpd/base/content_protection_element.h"
16 #include "packager/mpd/base/mpd_builder.h"
17 #include "packager/mpd/base/period.h"
18 #include "packager/mpd/base/representation.h"
19 
20 namespace shaka {
21 
22 class MockMpdBuilder : public MpdBuilder {
23  public:
25  ~MockMpdBuilder() override;
26 
27  MOCK_METHOD1(GetOrCreatePeriod, Period*(double start_time_in_seconds));
28  MOCK_METHOD1(ToString, bool(std::string* output));
29 };
30 
31 class MockPeriod : public Period {
32  public:
33  MockPeriod(uint32_t period_id, double start_time_in_seconds);
34 
35  MOCK_METHOD2(GetOrCreateAdaptationSet,
36  AdaptationSet*(const MediaInfo& media_info,
37  bool content_protection_in_adaptation_set));
38 
39  private:
40  // Only for constructing the super class. Not used for testing.
41  uint32_t sequence_counter_ = 0;
42 };
43 
45  public:
47  ~MockAdaptationSet() override;
48 
49  MOCK_METHOD1(AddRepresentation, Representation*(const MediaInfo& media_info));
50  MOCK_METHOD1(CopyRepresentation,
51  Representation*(const Representation& representation));
52  MOCK_METHOD1(AddContentProtectionElement,
53  void(const ContentProtectionElement& element));
54  MOCK_METHOD2(UpdateContentProtectionPssh,
55  void(const std::string& drm_uuid, const std::string& pssh));
56  MOCK_METHOD1(AddRole, void(AdaptationSet::Role role));
57  MOCK_METHOD1(ForceSetSegmentAlignment, void(bool segment_alignment));
58  MOCK_METHOD1(AddAdaptationSetSwitching,
59  void(const AdaptationSet* adaptation_set));
60  MOCK_METHOD1(AddTrickPlayReference,
61  void(const AdaptationSet* adaptation_set));
62 
63  private:
64  // Only for constructing the super class. Not used for testing.
65  uint32_t sequence_counter_ = 0;
66 };
67 
69  public:
70  // |representation_id| is the numeric ID for the <Representation>.
71  explicit MockRepresentation(uint32_t representation_id);
72  ~MockRepresentation() override;
73 
74  MOCK_METHOD1(AddContentProtectionElement,
75  void(const ContentProtectionElement& element));
76  MOCK_METHOD2(UpdateContentProtectionPssh,
77  void(const std::string& drm_uuid, const std::string& pssh));
78  MOCK_METHOD3(AddNewSegment,
79  void(int64_t start_time, int64_t duration, uint64_t size));
80  MOCK_METHOD1(SetSampleDuration, void(uint32_t sample_duration));
81  MOCK_CONST_METHOD0(GetMediaInfo, const MediaInfo&());
82 };
83 
84 } // namespace shaka
85 
86 #endif // MPD_BASE_MOCK_MPD_BUILDER_H_
shaka::Period
Definition: period.h:26
shaka::MpdBuilder::GetOrCreatePeriod
virtual Period * GetOrCreatePeriod(double start_time_in_seconds)
Definition: mpd_builder.cc:145
shaka::AdaptationSet::ForceSetSegmentAlignment
virtual void ForceSetSegmentAlignment(bool segment_alignment)
Definition: adaptation_set.cc:376
shaka::AdaptationSet
Definition: adaptation_set.h:33
shaka::Representation::AddNewSegment
virtual void AddNewSegment(int64_t start_time, int64_t duration, uint64_t size)
Definition: representation.cc:171
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::MpdBuilder::ToString
virtual bool ToString(std::string *output) WARN_UNUSED_RESULT
Definition: mpd_builder.cc:159
shaka::Representation::SetSampleDuration
virtual void SetSampleDuration(uint32_t sample_duration)
Definition: representation.cc:196
shaka::AdaptationSet::UpdateContentProtectionPssh
virtual void UpdateContentProtectionPssh(const std::string &drm_uuid, const std::string &pssh)
Definition: adaptation_set.cc:219
shaka::MockMpdBuilder
Definition: mock_mpd_builder.h:22
shaka::Period::start_time_in_seconds
double start_time_in_seconds() const
Definition: period.h:55
shaka::MpdBuilder
This class generates DASH MPDs (Media Presentation Descriptions).
Definition: mpd_builder.h:36
shaka::Representation
Definition: representation.h:50
shaka::AdaptationSet::AddRepresentation
virtual Representation * AddRepresentation(const MediaInfo &media_info)
Definition: adaptation_set.cc:179
shaka::Period::GetOrCreateAdaptationSet
virtual AdaptationSet * GetOrCreateAdaptationSet(const MediaInfo &media_info, bool content_protection_in_adaptation_set)
Definition: period.cc:74
shaka::MockRepresentation
Definition: mock_mpd_builder.h:68
shaka::AdaptationSet::AddContentProtectionElement
virtual void AddContentProtectionElement(const ContentProtectionElement &element)
Definition: adaptation_set.cc:213
shaka::AdaptationSet::CopyRepresentation
virtual Representation * CopyRepresentation(const Representation &representation)
Definition: adaptation_set.cc:198
shaka::AdaptationSet::AddAdaptationSetSwitching
virtual void AddAdaptationSetSwitching(const AdaptationSet *adaptation_set)
Definition: adaptation_set.cc:382
shaka::AdaptationSet::AddRole
virtual void AddRole(Role role)
Definition: adaptation_set.cc:230
shaka::MockAdaptationSet
Definition: mock_mpd_builder.h:44
shaka::Representation::AddContentProtectionElement
virtual void AddContentProtectionElement(const ContentProtectionElement &element)
Definition: representation.cc:159
shaka::MockPeriod
Definition: mock_mpd_builder.h:31
shaka::AdaptationSet::AddTrickPlayReference
virtual void AddTrickPlayReference(const AdaptationSet *adaptation_set)
Definition: adaptation_set.cc:410
shaka::Representation::UpdateContentProtectionPssh
virtual void UpdateContentProtectionPssh(const std::string &drm_uuid, const std::string &pssh)
Definition: representation.cc:165
shaka::Representation::GetMediaInfo
virtual const MediaInfo & GetMediaInfo() const
Definition: representation.cc:211
shaka::ContentProtectionElement
Definition: content_protection_element.h:36