Updated project files to VS2008 SP1. Removed deprecated features (and warning message...
[xiph/unicode.git] / oggdsf / src / lib / core / directshow / dsfOggDemux / OggStreamFactory.cpp
blobde1665c6859124afc63566f3a7b1a923336d1c1d
1 //===========================================================================
2 //Copyright (C) 2003, 2004 Zentaro Kavanagh
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions
6 //are met:
7 //
8 //- Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
11 //- Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
15 //- Neither the name of Zentaro Kavanagh nor the names of contributors
16 // may be used to endorse or promote products derived from this software
17 // without specific prior written permission.
19 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 //``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 //PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
23 //CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 //EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 //PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 //===========================================================================
31 #include "stdafx.h"
32 #include "oggstreamfactory.h"
36 OggStreamFactory::OggStreamFactory(void)
40 OggStreamFactory::~OggStreamFactory(void)
44 //New codecs need to be added here and write a derived Stream Class.
45 OggStream* OggStreamFactory::CreateStream(OggPage* inOggPage, OggDemuxSourceFilter* inOwningFilter, bool inAllowSeek) {
46 switch (OggStreamFactory::IdentifyCodec(inOggPage->getPacket(0))) {
47 case StreamHeaders::VORBIS:
48 return new VorbisStream(inOggPage, inOwningFilter, inAllowSeek);
49 case StreamHeaders::SPEEX:
50 return new SpeexStream(inOggPage, inOwningFilter, inAllowSeek);
51 case StreamHeaders::FLAC:
52 return new FLACStream(inOggPage, inOwningFilter, inAllowSeek);
53 case StreamHeaders::OGG_FLAC_1_0:
54 return new OggFLAC_1_0_Stream(inOggPage, inOwningFilter, inAllowSeek);
55 case StreamHeaders::THEORA:
56 return new TheoraStream(inOggPage, inOwningFilter, inAllowSeek);
57 case StreamHeaders::FFDSHOW_VIDEO:
58 return new FFDShowVideoStream(inOggPage, inOwningFilter, inAllowSeek);
59 case StreamHeaders::NONE:
60 default:
61 return NULL;
65 StreamHeaders::eCodecType OggStreamFactory::IdentifyCodec(OggPacket* inOggPacket) {
66 if (strncmp((char*)inOggPacket->packetData(), "\001vorbis", 7) == 0) {
67 return StreamHeaders::VORBIS;
68 } else if (strncmp((char*)inOggPacket->packetData(), "Speex ", 8) == 0) {
69 return StreamHeaders::SPEEX;
70 } else if ((strncmp((char*)inOggPacket->packetData(), "fLaC", 4)) == 0) {
71 return StreamHeaders::FLAC;
72 } else if ((strncmp((char*)inOggPacket->packetData(), "\177FLAC", 5)) == 0) {
73 return StreamHeaders::OGG_FLAC_1_0;
74 } else if ((strncmp((char*)inOggPacket->packetData(), "\200theora", 7)) == 0) {
75 return StreamHeaders::THEORA;
76 } else if ((strncmp((char*)inOggPacket->packetData(), "\001video\000\000\000", 9)) == 0) {
77 return StreamHeaders::FFDSHOW_VIDEO;
80 return StreamHeaders::NONE;