RE: AddOutputFilterByType

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay, this is great! Making some real headway here.

Your suggestions works as expected. However, I want to throw another spanner
in the works :)

I have a directory which only contains flac files. I have several bash
scripts, each of which convert a flac file to another format (mp3, aac, etc)

I've setup various custom filters for each using ExtFilterDefine, and they
all work as suggested. 

Now:

I could expand your suggestion of using SetEnvIf to pass through the value
of the quality field for each mimetype I want to support. This would be a
fine solution, and would work.

However, I'm interested in seeing if I can get MultiViews to work with
directives provided by mod_filter. It is my understanding that:

MultiViewsMatch Filters

Would tell Apache to check the mime-types of any attached filters and apply
those in order to provide the requested resource.

Here is a pseudo-example of what I've configured:

ExtFilterDefine Transcode_MP3 mode=output intype=audio/flac
outtype=audio/mp3 cmd="flac2mp3"
ExtFilterDefine Transcode_AAC mode=output intype=audio/flac
outtype=audio/aac cmd="flac2aac"
ExtFilterDefine Transcode_MP4 mode=output intype=audio/flac
outtype=audio/mp4 cmd="flac2mp4"

<Directory /mylib>

	Options MultiViews

	MultiViewsMatch Filters
	
	FilterProvider Transcode_MP3 ext_filter Content-type audio/mp3
	FilterProvider Transcode_AAC ext_filter Content-type audio/aac
	FilterProvider Transcode_MP4 ext_filter Content-type audio/mp4

	FilterChain Transcode_MP3 Transcode_AAC Transcode_MP4

</Directory>
Alias /lib /mylib

The directory /mylib only contains flac files.

So, in theory, I should be able to make the following request:

GET /lib/song1
Accept: audio/mp3;q=1,audio/aac;q=0.5

And the process should be:

1) MultiViews fires up and tries to conneg the file. Matches the audio/mp3
type from the Accept header.
2) Matches the file /mylib/song1.flac
3) Passes the file out through the custom filter Transcode_MP3 (flac2mp3
script)
4) Returns song1.mp3

Can anyone give me some advice? My main concerns are regarding the process
Apache goes through to accomplish this:

1) The Second parameter of FilterProvider should be the provider-name. In
the example above, Apache refuses to start if I use "ext_filter", but
replacing it with "Transcode_MP3" lets it start (the thinking is that the
provider-name is the custom filter name I have previously setup using
ExtFilterDefine, but I think this may be wrong)

2) I think I may have made a incorrect assumption that multiviews will grab
the song1.flac file and pass it through to the appropriate filter. Is this
correct? If "MultiViewsMatch Filters" is used, will MultiViews pass through
the first file that *could* match to the appropriate filter? I couldn't find
any further information on what happens with this directive from the Apache
2.2 Documentation.

3) This may seem like a long winded way of doing things, but I am interested
in running my custom filter as much like "real" filters as possible, so that
in the future I could replace them with properly coded "real" filters :).
That and I really want to understand Apache Filters better, and considering
Apache source code is way out of my league, custom/script filters are about
the best I can cope with. If I can do pretty much everything you can with
custom/script filters you can do with "real" filters, that would definitely
help my understanding.

If you have a better, more in-depth reference for filters (besides the
Apache 2.2 Documentation), please send me the link, and I'll quit bothering
the list :)

Again, thanks for your help so far.

Cheers,

Ben



Ben Davies | Lead Developer | Stickyeyes
6th Floor, 
West One, 
Wellington Street, 
Leeds, LS1 1BA 
Email: ben.davies@xxxxxxxxxxxxxx
0113 391 2929 | Fax 0113 391 2939

This e-mail may contain information that is privileged, confidential or
otherwise protected from disclosure. It must not be used by, or its contents
copied or disclosed to persons other than the intended recipient. Any
liability (in negligence or otherwise) arising from any third party acting,
or refraining from acting, on any information contained in this e-mail is
excluded. The views expressed may not be official company policy, but
instead, the personal views of the originator. If you have received this
e-mail in error please notify the sender and delete the e-mail.


-----Original Message-----
From: jslive@xxxxxxxxx [mailto:jslive@xxxxxxxxx] On Behalf Of Joshua Slive
Sent: 02 June 2008 17:28
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  AddOutputFilterByType

On Mon, Jun 2, 2008 at 11:50 AM, Ben Davies <ben@xxxxxxxxxxxxxx> wrote:
> Sorry, I should have been more explicit:
>
> How would you implement AddOutputFilterByType for filters created with
> ExtFilterDefine?
>
> Example:
>
> I have a flac file. I have a custom filter that converts flac files to mp3
> files. If the request contains the header Accept: audio/mp3, how can I
> ensure that my custom filter will run?
>
> I had a look at the directives for mod_filter and the closest match
appears
> to be FilterProvider, but the second argument requires that I specify a
> regular filter.

mod_ext_filter does create "regular" filters that should be usable in
a FilterProvider directive. (Although I have never tried it myself.)

Alternatively, mod_ext_filter has its own set of triggers. For
example, the AddOutputFilterByType directive can be easily replaced by
specifying an intype= argument for your ExtFilterDefine directive. If
you really want to match off the Accept request header (rather than
imitating AddOutputFilterByType as you initially requested), you can
do something like

SetEnvIf Accept audio/mp3 accept-mp3
ExtFilterDefine ... enableenv=accept-mp3

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux