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 "ISOControl.h" |
michael@0 | 7 | #include "ISOMediaBoxes.h" |
michael@0 | 8 | #include "AMRBox.h" |
michael@0 | 9 | #include "ISOTrackMetadata.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | |
michael@0 | 13 | nsresult |
michael@0 | 14 | AMRSampleEntry::Generate(uint32_t* aBoxSize) |
michael@0 | 15 | { |
michael@0 | 16 | uint32_t box_size; |
michael@0 | 17 | nsresult rv = amr_special_box->Generate(&box_size); |
michael@0 | 18 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 19 | size += box_size; |
michael@0 | 20 | |
michael@0 | 21 | *aBoxSize = size; |
michael@0 | 22 | return NS_OK; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | nsresult |
michael@0 | 26 | AMRSampleEntry::Write() |
michael@0 | 27 | { |
michael@0 | 28 | BoxSizeChecker checker(mControl, size); |
michael@0 | 29 | nsresult rv; |
michael@0 | 30 | rv = AudioSampleEntry::Write(); |
michael@0 | 31 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 32 | rv = amr_special_box->Write(); |
michael@0 | 33 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 34 | |
michael@0 | 35 | return NS_OK; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | AMRSampleEntry::AMRSampleEntry(ISOControl* aControl) |
michael@0 | 39 | : AudioSampleEntry(NS_LITERAL_CSTRING("samr"), aControl) |
michael@0 | 40 | { |
michael@0 | 41 | amr_special_box = new AMRSpecificBox(aControl); |
michael@0 | 42 | MOZ_COUNT_CTOR(AMRSampleEntry); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | AMRSampleEntry::~AMRSampleEntry() |
michael@0 | 46 | { |
michael@0 | 47 | MOZ_COUNT_DTOR(AMRSampleEntry); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | nsresult |
michael@0 | 51 | AMRSpecificBox::Generate(uint32_t* aBoxSize) |
michael@0 | 52 | { |
michael@0 | 53 | nsresult rv; |
michael@0 | 54 | FragmentBuffer* frag = mControl->GetFragment(Audio_Track); |
michael@0 | 55 | rv = frag->GetCSD(amrDecSpecInfo); |
michael@0 | 56 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 57 | |
michael@0 | 58 | size += amrDecSpecInfo.Length(); |
michael@0 | 59 | *aBoxSize = size; |
michael@0 | 60 | |
michael@0 | 61 | return NS_OK; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | nsresult |
michael@0 | 65 | AMRSpecificBox::Write() |
michael@0 | 66 | { |
michael@0 | 67 | BoxSizeChecker checker(mControl, size); |
michael@0 | 68 | Box::Write(); |
michael@0 | 69 | mControl->Write(amrDecSpecInfo.Elements(), amrDecSpecInfo.Length()); |
michael@0 | 70 | return NS_OK; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | AMRSpecificBox::AMRSpecificBox(ISOControl* aControl) |
michael@0 | 74 | : Box(NS_LITERAL_CSTRING("damr"), aControl) |
michael@0 | 75 | { |
michael@0 | 76 | MOZ_COUNT_CTOR(AMRSpecificBox); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | AMRSpecificBox::~AMRSpecificBox() |
michael@0 | 80 | { |
michael@0 | 81 | MOZ_COUNT_DTOR(AMRSpecificBox); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | } |