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
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include <climits> |
michael@0 | 7 | #include "ISOControl.h" |
michael@0 | 8 | #include "ISOMediaBoxes.h" |
michael@0 | 9 | #include "AVCBox.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | |
michael@0 | 13 | nsresult |
michael@0 | 14 | AVCSampleEntry::Generate(uint32_t* aBoxSize) |
michael@0 | 15 | { |
michael@0 | 16 | uint32_t avc_box_size = 0; |
michael@0 | 17 | nsresult rv; |
michael@0 | 18 | rv = avcConfigBox->Generate(&avc_box_size); |
michael@0 | 19 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 20 | |
michael@0 | 21 | size += avc_box_size; |
michael@0 | 22 | |
michael@0 | 23 | *aBoxSize = size; |
michael@0 | 24 | |
michael@0 | 25 | return NS_OK; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | nsresult |
michael@0 | 29 | AVCSampleEntry::Write() |
michael@0 | 30 | { |
michael@0 | 31 | BoxSizeChecker checker(mControl, size); |
michael@0 | 32 | nsresult rv; |
michael@0 | 33 | rv = VisualSampleEntry::Write(); |
michael@0 | 34 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 35 | rv = avcConfigBox->Write(); |
michael@0 | 36 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 37 | |
michael@0 | 38 | return NS_OK; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | AVCSampleEntry::AVCSampleEntry(ISOControl* aControl) |
michael@0 | 42 | : VisualSampleEntry(NS_LITERAL_CSTRING("avc1"), aControl) |
michael@0 | 43 | { |
michael@0 | 44 | avcConfigBox = new AVCConfigurationBox(aControl); |
michael@0 | 45 | MOZ_COUNT_CTOR(AVCSampleEntry); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | AVCSampleEntry::~AVCSampleEntry() |
michael@0 | 49 | { |
michael@0 | 50 | MOZ_COUNT_DTOR(AVCSampleEntry); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | AVCConfigurationBox::AVCConfigurationBox(ISOControl* aControl) |
michael@0 | 54 | : Box(NS_LITERAL_CSTRING("avcC"), aControl) |
michael@0 | 55 | { |
michael@0 | 56 | MOZ_COUNT_CTOR(AVCConfigurationBox); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | AVCConfigurationBox::~AVCConfigurationBox() |
michael@0 | 60 | { |
michael@0 | 61 | MOZ_COUNT_DTOR(AVCConfigurationBox); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | nsresult |
michael@0 | 65 | AVCConfigurationBox::Generate(uint32_t* aBoxSize) |
michael@0 | 66 | { |
michael@0 | 67 | nsresult rv; |
michael@0 | 68 | FragmentBuffer* frag = mControl->GetFragment(Video_Track); |
michael@0 | 69 | rv = frag->GetCSD(avcConfig); |
michael@0 | 70 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 71 | size += avcConfig.Length(); |
michael@0 | 72 | *aBoxSize = size; |
michael@0 | 73 | return NS_OK; |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | nsresult |
michael@0 | 77 | AVCConfigurationBox::Write() |
michael@0 | 78 | { |
michael@0 | 79 | BoxSizeChecker checker(mControl, size); |
michael@0 | 80 | Box::Write(); |
michael@0 | 81 | |
michael@0 | 82 | mControl->Write(avcConfig.Elements(), avcConfig.Length()); |
michael@0 | 83 | |
michael@0 | 84 | return NS_OK; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | } |