Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include <climits>
7 #include "ISOControl.h"
8 #include "ISOMediaBoxes.h"
9 #include "AVCBox.h"
11 namespace mozilla {
13 nsresult
14 AVCSampleEntry::Generate(uint32_t* aBoxSize)
15 {
16 uint32_t avc_box_size = 0;
17 nsresult rv;
18 rv = avcConfigBox->Generate(&avc_box_size);
19 NS_ENSURE_SUCCESS(rv, rv);
21 size += avc_box_size;
23 *aBoxSize = size;
25 return NS_OK;
26 }
28 nsresult
29 AVCSampleEntry::Write()
30 {
31 BoxSizeChecker checker(mControl, size);
32 nsresult rv;
33 rv = VisualSampleEntry::Write();
34 NS_ENSURE_SUCCESS(rv, rv);
35 rv = avcConfigBox->Write();
36 NS_ENSURE_SUCCESS(rv, rv);
38 return NS_OK;
39 }
41 AVCSampleEntry::AVCSampleEntry(ISOControl* aControl)
42 : VisualSampleEntry(NS_LITERAL_CSTRING("avc1"), aControl)
43 {
44 avcConfigBox = new AVCConfigurationBox(aControl);
45 MOZ_COUNT_CTOR(AVCSampleEntry);
46 }
48 AVCSampleEntry::~AVCSampleEntry()
49 {
50 MOZ_COUNT_DTOR(AVCSampleEntry);
51 }
53 AVCConfigurationBox::AVCConfigurationBox(ISOControl* aControl)
54 : Box(NS_LITERAL_CSTRING("avcC"), aControl)
55 {
56 MOZ_COUNT_CTOR(AVCConfigurationBox);
57 }
59 AVCConfigurationBox::~AVCConfigurationBox()
60 {
61 MOZ_COUNT_DTOR(AVCConfigurationBox);
62 }
64 nsresult
65 AVCConfigurationBox::Generate(uint32_t* aBoxSize)
66 {
67 nsresult rv;
68 FragmentBuffer* frag = mControl->GetFragment(Video_Track);
69 rv = frag->GetCSD(avcConfig);
70 NS_ENSURE_SUCCESS(rv, rv);
71 size += avcConfig.Length();
72 *aBoxSize = size;
73 return NS_OK;
74 }
76 nsresult
77 AVCConfigurationBox::Write()
78 {
79 BoxSizeChecker checker(mControl, size);
80 Box::Write();
82 mControl->Write(avcConfig.Elements(), avcConfig.Length());
84 return NS_OK;
85 }
87 }