1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/WebVTTListener.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_dom_WebVTTLoadListener_h 1.10 +#define mozilla_dom_WebVTTLoadListener_h 1.11 + 1.12 +#include "nsIWebVTTListener.h" 1.13 +#include "nsIStreamListener.h" 1.14 +#include "nsIChannelEventSink.h" 1.15 +#include "nsAutoPtr.h" 1.16 +#include "nsIInterfaceRequestor.h" 1.17 +#include "nsCycleCollectionParticipant.h" 1.18 + 1.19 +class nsIWebVTTParserWrapper; 1.20 + 1.21 +namespace mozilla { 1.22 +namespace dom { 1.23 + 1.24 +class HTMLTrackElement; 1.25 + 1.26 +class WebVTTListener MOZ_FINAL : public nsIWebVTTListener, 1.27 + public nsIStreamListener, 1.28 + public nsIChannelEventSink, 1.29 + public nsIInterfaceRequestor 1.30 +{ 1.31 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.32 + NS_DECL_NSIWEBVTTLISTENER 1.33 + NS_DECL_NSIREQUESTOBSERVER 1.34 + NS_DECL_NSISTREAMLISTENER 1.35 + NS_DECL_NSICHANNELEVENTSINK 1.36 + NS_DECL_NSIINTERFACEREQUESTOR 1.37 + 1.38 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebVTTListener, 1.39 + nsIStreamListener) 1.40 + 1.41 +public: 1.42 + WebVTTListener(HTMLTrackElement* aElement); 1.43 + ~WebVTTListener(); 1.44 + 1.45 + /** 1.46 + * Loads the WebVTTListener. Must call this in order for the listener to be 1.47 + * ready to parse data that is passed to it. 1.48 + */ 1.49 + nsresult LoadResource(); 1.50 + 1.51 +private: 1.52 + // List of error codes returned from the WebVTT parser that we care about. 1.53 + enum ErrorCodes { 1.54 + BadSignature = 0 1.55 + }; 1.56 + static NS_METHOD ParseChunk(nsIInputStream* aInStream, void* aClosure, 1.57 + const char* aFromSegment, uint32_t aToOffset, 1.58 + uint32_t aCount, uint32_t* aWriteCount); 1.59 + 1.60 + nsRefPtr<HTMLTrackElement> mElement; 1.61 + nsCOMPtr<nsIWebVTTParserWrapper> mParserWrapper; 1.62 +}; 1.63 + 1.64 +} // namespace dom 1.65 +} // namespace mozilla 1.66 + 1.67 +#endif // mozilla_dom_WebVTTListener_h